fix(typescript-fetch): skip scalar enum comparison for array-typed properties in instanceOf#24217
Merged
wing328 merged 2 commits intoJul 7, 2026
Conversation
…ies in instanceOf The instanceOf guard was emitting an invalid scalar !== comparison for required properties typed as Array<SingleValueEnum>, introduced as a side effect of PR OpenAPITools#23497. The enum-literal check block now only fires for non-container (scalar) properties
…tch-instanceof-array-enum
Member
|
tested locally and the change looks good. thanks for the fix |
Member
|
cc @jasperpatterson who's the author of #23497. |
Member
We appreciate you and your team contributing back to make this project better. |
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.
Required properties typed as
Array<SingleValueEnum>triggered two bugs in theinstanceOfguard (side effect of #23497):value['types'] !== 'x'against an array is always truthy, permanently breakinginstanceOf.isStringresolves against the container type (Array), not the item type, so the literal was emitted unquoted (boatbooker_activitiesinstead of'boatbooker_activities'), causingTS2304: Cannot find name.Fix: wrap the enum-literal block in
{{^isContainer}}so it only fires for scalar properties. Scalar enum behavior is unchanged.Apologies for the burst of PRs in a short time — we are integrating this generator into production at FishingBooker and kept uncovering issues along the way.
Also sorry for skipping a prior issue on this one; if a release is coming soon we'd love to see it included. Happy to open a follow-up issue if preferred.
Fixes a regression introduced by #23497.
PR checklist
./mvnw test -pl modules/openapi-generator -Dtest=TypeScriptFetchClientCodegenTest./bin/generate-samples.sh ./bin/configs/typescript-fetch*cc @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @dennisameling
Summary by cubic
Fixes the
instanceOfguard intypescript-fetchto skip scalar enum comparisons for array-typed enum properties (e.g.,Array<SingleValueEnum>), preventing false negatives and TypeScript literal name errors. Scalar enum behavior is unchanged.{{^isContainer}}inmodelGeneric.mustacheso array enums no longer emit invalid!==comparisons or unquoted literals.testInstanceOfArrayEnumNoScalarComparison) with a minimal OpenAPI fixture to verify no scalar comparison is emitted and the field presence check remains.Written for commit 6018a9d. Summary will update on new commits.