Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emitter framework handle circular references #2550

Merged

Conversation

timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented Oct 10, 2023

Emitter framework deals with circular reference for you and this works great if the circular flow involve declarations that can be referenced. But sometimes there is issues where we can't have a declaration and so a circular reference becomes impossible. Adding a new circularReference hook that gets called when we resolve a reference that is point back to itself in the resolution stack. By default it will throw resolve the declaration ref if the target is a declaration or throw an error.

An emitter can decide to override this function to provide a different handling in either cases. A target language might not even support circular reference at all.

@timotheeguerin timotheeguerin changed the title Emitter framework circular Emitter framework handle circular references Oct 10, 2023
@github-actions
Copy link
Contributor

Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status):
Playground: https://cadlplayground.z22.web.core.windows.net/prs/2550/

Website: https://tspwebsitepr.z22.web.core.windows.net/prs/2550/

@timotheeguerin timotheeguerin merged commit ad2aaca into microsoft:main Oct 20, 2023
12 checks passed
@timotheeguerin timotheeguerin deleted the emitter-framework-circular branch October 20, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants