Conversation
…ant duplicateDefaultVariant message Co-authored-by: baywet <[email protected]>
Copilot
AI
changed the title
[WIP] Fix error message for invalid discriminated union variant
fix(compiler): include union type name in Mar 30, 2026
invalid-discriminated-union-variant diagnostic
baywet
approved these changes
Mar 30, 2026
commit: |
Collaborator
|
You can try these changes here
|
timotheeguerin
approved these changes
Mar 30, 2026
msyyc
pushed a commit
that referenced
this pull request
Apr 1, 2026
…n-variant` diagnostic (#10199) The `duplicateDefaultVariant` message for `invalid-discriminated-union-variant` was a static string with no context about which union triggered the error, making it hard to act on. ## Changes - **`messages.ts`**: Convert `duplicateDefaultVariant` from a static string to a `paramMessage` template accepting a `unionName` parameter - **`discriminator-utils.ts`**: Pass `format: { unionName: type.name ?? "(anonymous)" }` to the diagnostic - **`decorators.test.ts`**: Update test assertion to match the new message format ### Before / After ``` // Before Discriminated union only allow a single default variant(Without a variant name). // After Discriminated union Foo only allow a single default variant(Without a variant name). ``` --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: baywet <[email protected]>
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
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.
The
duplicateDefaultVariantmessage forinvalid-discriminated-union-variantwas a static string with no context about which union triggered the error, making it hard to act on.Changes
messages.ts: ConvertduplicateDefaultVariantfrom a static string to aparamMessagetemplate accepting aunionNameparameterdiscriminator-utils.ts: Passformat: { unionName: type.name ?? "(anonymous)" }to the diagnosticdecorators.test.ts: Update test assertion to match the new message formatBefore / After