Repository navigation
Bound printing of deferred array and tuple references by their node - #65544
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Printing a type stops nesting once enough types with the same identity
are nested, but array and tuple types have none, so that an array
written out with finite nesting is printed in full. A recursive type
whose instantiations nest arrays through a conditional type, such as
type G<T> = T extends unknown ? (T | G<[T]>)[] : never;
creates a new deferred array reference at each level, so printing
G<"x"> with noErrorTruncation, or in declaration emit, recursed until
the stack overflowed. A deferred array or tuple reference nests through
its node, as any other deferred reference does, so printing it stops
at the same depth as for those.
Fixes 64683
Jake Bailey (jakebailey)
requested review from
Ryan Cavanaugh (RyanCavanaugh) and
Wesley Wigham (weswigham)
and
a balanced review from Copilot
November 17, 2026 05:50
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change restoring bounded printing of deferred array and tuple references.
No open issues 🎉
What changed in this PR
Fixes #64683, a regression from #64556, by restoring bounded printing of deferred array and tuple references in the native TypeScript compiler.
Changes:
- Checks deferred references before the array/tuple exemption, using their syntax nodes to bound recursive printing.
- Adds an expanding recursive-type regression case with
noErrorTruncationenabled. - Updates baselines to record bounded type output and expected diagnostics.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/recursiveContainerDeclarationSerialization.ts |
Adds regression coverage for expanding recursive types. |
tsc/testdata/baselines/reference/compiler/recursiveContainerDeclarationSerialization.types |
Records bounded type serialization. |
tsc/testdata/baselines/reference/compiler/recursiveContainerDeclarationSerialization.symbols |
Records symbols for the new test case. |
tsc/testdata/baselines/reference/compiler/recursiveContainerDeclarationSerialization.js |
Updates source and emitted JavaScript baselines. |
tsc/testdata/baselines/reference/compiler/recursiveContainerDeclarationSerialization.errors.txt |
Records serialization-limit and assignment diagnostics. |
tsc/internal/checker/nodebuilderimpl.go |
Prioritizes node-based bounds for deferred references. |
Review effort: Balanced
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.
This was effectively a regression in #64556. Type references needed to be checked first.
Fixes #64683