-
Notifications
You must be signed in to change notification settings - Fork 295
[emitter-framework] Render discriminated unions correctly #7369
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
All changed packages have been documented.
|
You can try these changes here
|
packages/emitter-framework/test/typescript/components/union-declaration.test.tsx
Outdated
Show resolved
Hide resolved
packages/emitter-framework/test/typescript/components/union-declaration.test.tsx
Outdated
Show resolved
Hide resolved
packages/emitter-framework/src/typescript/components/union-expression.tsx
Outdated
Show resolved
Hide resolved
maorleger
commented
May 19, 2025
packages/emitter-framework/src/typescript/components/union-expression.tsx
Outdated
Show resolved
Hide resolved
bterlson
reviewed
May 20, 2025
packages/emitter-framework/test/typescript/components/union-declaration.test.tsx
Show resolved
Hide resolved
bterlson
reviewed
May 20, 2025
packages/emitter-framework/test/typescript/components/union-declaration.test.tsx
Show resolved
Hide resolved
bterlson
approved these changes
May 20, 2025
ArcturusZhang
pushed a commit
to ArcturusZhang/typespec
that referenced
this pull request
May 21, 2025
…7369) This pull request enhances the handling of discriminated unions in the `@typespec/emitter-framework` package. It introduces new rendering logic for discriminated unions, updates existing components to support these changes, and improves test coverage to validate the new functionality. ### Enhancements to discriminated union rendering: * Added new rendering logic for discriminated unions, including support for "object" and "none" envelope styles, through the `ObjectEnvelope` and `NoneEnvelope` functions in `union-expression.tsx`. These handle different discriminator configurations and ensure proper rendering of union variants. [[1]](diffhunk://#diff-400029c681b8e2281a1bde7777af749a18d635dcf9ddaa4a6c9cb1bd86301fe7L22-R27) [[2]](diffhunk://#diff-400029c681b8e2281a1bde7777af749a18d635dcf9ddaa4a6c9cb1bd86301fe7R38-R127) ### Updates to existing components: * Modified the `InterfaceBody` component in `interface-declaration.tsx` to include a semicolon when rendering type members, ensuring consistency with TypeScript syntax. Found in passing and validated via the new tests ### Improvements to test coverage: * Refactored and expanded tests in `union-declaration.test.tsx` using the new testing patterns Fixes microsoft#7174
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request enhances the handling of discriminated unions in the
@typespec/emitter-framework
package. It introduces new rendering logic for discriminated unions, updates existing components to support these changes, and improves test coverage to validate the new functionality.Enhancements to discriminated union rendering:
ObjectEnvelope
andNoneEnvelope
functions inunion-expression.tsx
. These handle different discriminator configurations and ensure proper rendering of union variants. [1] [2]Updates to existing components:
InterfaceBody
component ininterface-declaration.tsx
to include a semicolon when rendering type members, ensuring consistency with TypeScript syntax. Found in passing and validated via the new testsImprovements to test coverage:
union-declaration.test.tsx
using the new testing patternsFixes #7174