Repository navigation
Conversation
This branch has not been deployed
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.
With
taggedUnions=truemodel that is plainoneOfwithout discriminator is generated as empty interface, for spec from issuezooInner.tsgetsexport interface ZooInner { }instead ofexport type ZooInner = Cat | Dog;, so narrowing onz.typefails with TS2339Without
taggedUnionssame model is allready unionWhen option is on
model.mustachesends every model except enums and aliases tomodelTaggedUnion.mustache, and there branch for model without discriminator and parent renders onlymodelGenericNow that branch picks
modelOneOfforoneOfmodels, same checkmodel.mustachedoes when option is off, models with discriminator or parent are not touchedAdded
testTaggedUnionsOneOfWithoutDiscriminatorwith spec from issue, it fails on masterClient generated from that spec now compiles with strict
tsc, narrowing ontypeincludedSample config with
taggedUnions(composed-schemas) has nooneOf, so regenerated typescript-angular samples have no diffFixes #20859
PR checklist
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
Summary by cubic
Fixes
typescript-angulargenerating an empty interface foroneOfmodels without a discriminator whentaggedUnions=trueis enabled, instead of a union type likeexport type ZooInner = Cat | Dog;. This caused type narrowing onz.typeto fail with TS2339.The tagged union template now falls back to the standard oneOf generation for models that have
oneOfbut no discriminator or parent; models with a discriminator or parent are unchanged. Adds a regression test with the spec from issue #20859.Written for commit 38be3c1. Summary will update on new commits.