Conversation
API clients can send printNode and formatNodeForInsertion a tree containing a JSDocTypeLiteral with property tags or a SyntaxList with children. Decoding either panicked: the generated decoder reserves capacity for these raw child lists, then indexes into them as though they already had that length.
Jake Bailey (jakebailey)
requested review from
Andrew Branch (andrewbranch)
and
a balanced review from Copilot
December 1, 2026 18:35
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the raw AST child-list decoding fix.
No open issues 🎉
1 file not reviewed
tsc/internal/api/encoder/decoder_generated.go: Generated file
What changed in this PR
Fixes raw AST child-list decoding in the Go API decoder by appending into reserved slice storage, avoiding out-of-range writes to zero-length slices.
Changes:
- Updates the decoder generator and generated handling for
SyntaxListandJSDocTypeLiteral. - Adds regression tests for empty, single-child, and multi-child lists, checking child order, scalar data, and encoding round trips.
| File | Description |
|---|---|
tsc/internal/api/encoder/decoder_test.go |
Adds raw child-list decoding regression tests. |
tsc/internal/api/encoder/decoder_generated.go |
Replaces indexed writes with appends for both affected node kinds. |
tools/scripts/tsc/generate-encoder.ts |
Preserves the append-based fix during regeneration. |
Review effort: Balanced
Wesley Wigham (weswigham)
approved these changes
Dec 1, 2026
Wesley Wigham (weswigham)
left a comment
Member
There was a problem hiding this comment.
I'm guessing the difference is in len results, unlike in js where these'd be identical.
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.
allocNodeSlicereturns an empty slice with the requested cap, so needs to be appended to, not assigned to.