Skip to content

[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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

maorleger
Copy link
Member

@maorleger maorleger commented May 15, 2025

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] [2]

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 #7174

Copy link
Contributor

github-actions bot commented May 15, 2025

All changed packages have been documented.

  • @typespec/emitter-framework
Show changes

@typespec/emitter-framework - fix ✏️

Render discriminated unions correctly

@azure-sdk
Copy link
Collaborator

azure-sdk commented May 15, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@maorleger maorleger marked this pull request as ready for review May 15, 2025 22:14
@maorleger maorleger requested a review from joheredi May 19, 2025 14:26
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.

[Bug]: TypeScript Emitter Framework does not handle new discriminated unions
4 participants