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.
Property like
bar: {anyOf: [{type: number}, {type: string}]}gets flattened intoFooBarmodel, and since that model has no own properties typescript-angular renders it as emptyexport interface FooBar { }So
baracepts any value, and reading it asnumber | stringfails with TS2322 without castmodel.mustacherendersoneOfmodel as union, but has no such branch foranyOf, so it falls intomodelGenericNow
anyOfmodel without own properties goes through newmodelAnyOf.mustache(likemodelOneOf.mustache) and givesexport type FooBar = number | string;anyOfof objects gets merged properties, sohasVarskeeps it onmodelGenericand its interface does not changeanyOfof models that extend discriminator parent was empty interface too (their properties go only toallVars), now it also becomes union of these modelsAdded
testAnyOfOfPrimitivesGeneratesUnionTypetoTypeScriptAngularClientCodegenTest, union check fails on masterNo typescript-angular sample spec has
anyOf, so regenerated samples (typescript-angular*.yamlconfigs) have no diffFixes #13428
PR checklist
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
Summary by cubic
Fixes typescript-angular codegen so properties with
anyOfof primitives generate union types likenumber | stringinstead of empty interfaces. Previously these flattened intoexport interface FooBar { }, which made the property accept any value and caused TS2322 when reading it as the union without a cast.anyOfof objects still merges properties into an interface. AddsmodelAnyOf.mustacheand a regression test that fails on master.Written for commit 9c4f6aa. Summary will update on new commits.