fix(geojson): correct array precedence in the generated codegen type#3089
Open
ifeanyi-ugwu wants to merge 1 commit into
Open
fix(geojson): correct array precedence in the generated codegen type#3089ifeanyi-ugwu wants to merge 1 commit into
ifeanyi-ugwu wants to merge 1 commit into
Conversation
generatePositionType() returned an unparenthesized union, so arrayed
usages (`${generatePositionType()}[]`) applied `[]` to only the second
member: `[number, number] | [number, number, number][]` instead of
`([number, number] | [number, number, number])[]`. The codegenScalarType
string emitted to GraphQL Codegen consumers was therefore wrong for
MultiPoint, LineString, MultiLineString, Polygon and MultiPolygon (every
geometry whose coordinates are arrays of positions).
ardatan
reviewed
Jul 10, 2026
ardatan
left a comment
Contributor
There was a problem hiding this comment.
Is this right way to reproduce and test this?
Maybe there should be a better test suite to check if the generated types work with your use case?
ifeanyi-ugwu
force-pushed
the
fix/geojson-codegen-type
branch
from
July 10, 2026 16:03
32af669 to
0881b6f
Compare
Contributor
Author
You're right, the test is weak — a drop-in. I found this while I was poking around codegen-test/, the dormant type-generation harness, and the real check belongs there. I kept it out of this PR because it wires into CI (the root test script) and shouldn't ride along with a one-line fix. I've opened #3092 for it and dropped the string assertion here. |
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.
generateGeoJSONType()builds the GeoJSONcodegenScalarTypeby interpolating the Position type into${Position}[]. Because the postfix[]binds tighter than|in TypeScript, the unparenthesized unionparses as "a 2-tuple or an array of 3-tuples" rather than "an array of Positions". The generated codegen type is therefore wrong for every geometry whose coordinates are arrays of positions — MultiPoint, LineString, MultiLineString, Polygon and MultiPolygon — rejecting valid coordinates like
[[1, 2], [3, 4]]while accepting a bare[1, 2].Parenthesizing the Position union at its source corrects all arrayed usages:
A regression test asserts the emitted type groups the union before applying
[].