feat(typediagram): add discriminants, untagged unions, and target gating#32
Merged
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
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.
TLDR
Add three typeDiagram language features end-to-end: explicit numeric union discriminants,
untagged unionsyntax, and declaration-level target gating with@targets(...)/@skipTargets(...), and teach converters/rendering/docs to honor them. Closes #25, closes #26, closes #27.Details
Added:
ParseError = -32700untagged unionparsing/modeling/printing, with Rust#[serde(untagged)]emission and plain TypeScript union emission@targets(...)and@skipTargets(...)packages/typediagram/src/variant.tsChanged:
typediagram-coreincreased to 80 KB to account for the added parser/emitter surfaceDeleted:
Spec/Doc changes:
docs/specs/language-reference.mdgrammar and examples for explicit numeric discriminantspackages/typediagram/README.mdwith discriminant examplesBreaking changes:
How Do The Automated Tests Prove It Works?
packages/typediagram/test/converters/rust.test.tspreserves explicit numeric discriminants on enum variantsemits serde untagged enums from untagged union syntaxpackages/typediagram/test/converters/typescript.test.tsemits untagged tuple unions as plain TypeScript unionsemits remaining untagged payload shapes without discriminator fields[CONV-TS-BUG-27] skips declarations gated away from the typescript target[CONV-TS-BUG-27] supports blacklisting the typescript targetpackages/typediagram/test/parser.test.tsparses untagged unionsparses target annotations on declarationspackages/typediagram/test/model.test.tspreserves untagged unions through printSource and JSONpreserves declaration target gating through printSource and JSONfilters declarations for a specific targetpackages/typediagram/test/render.test.tsrenders explicit union discriminants in the SVG textmake cipassed locally, including full Playwright coverage merge and the final bundle-size check (79.38 KBwithin the80 KBbudget)