typespec icon indicating copy to clipboard operation
typespec copied to clipboard

[emitter-framework] Render discriminated unions correctly

Open maorleger opened this issue 5 months ago • 2 comments

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

maorleger avatar May 15 '25 20:05 maorleger