Handle recursive aliases in named tuple rest elements#4444
Open
Copilot wants to merge 5 commits into
Open
Conversation
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
RyanCavanaugh
June 25, 2026 16:07
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a checker circularity regression where recursive type aliases using named tuple rest elements (e.g. ...tagged: T[]) could trigger a spurious TS2456 circular reference error, despite being structurally equivalent to unnamed rest elements.
Changes:
- Extend
Checker.mayResolveTypeAliasto recurse intoArrayTypeelement types, matching the existing deferral behavior already applied toRestTypewrapping an array. - Add a compiler regression test covering recursive aliases with both unnamed and named tuple rest members (named rest in the first branch and in a later tuple position).
- Add new reference baselines (
.types,.symbols,.js) for the new test.
Show a summary per file
| File | Description |
|---|---|
internal/checker/checker.go |
Makes alias-resolution deferral logic see through ArrayType nodes so named tuple rest members don’t force eager alias resolution. |
testdata/tests/cases/compiler/issue63584NamedTupleRestCircularReference.ts |
New regression test for recursive aliases with named vs unnamed tuple rest elements. |
testdata/baselines/reference/compiler/issue63584NamedTupleRestCircularReference.types |
Expected type baseline for the new regression test. |
testdata/baselines/reference/compiler/issue63584NamedTupleRestCircularReference.symbols |
Expected symbol baseline for the new regression test. |
testdata/baselines/reference/compiler/issue63584NamedTupleRestCircularReference.js |
Expected JS baseline for the new regression test. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 0
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 addresses microsoft/TypeScript#63584.
Recursive aliases using named tuple rest elements like
...tagged: T[]were being treated differently from structurally equivalent unnamed rest elements, producing a spurious TS2456 circularity error.Root cause
RestTypespecially, but missed theArrayTypenested underNamedTupleMember....name: T[]could force eager alias resolution where...T[]would defer.Checker change
mayResolveTypeAliasto recurse throughArrayTypenodes.Regression coverage