Skip to content

Fixed a crash related to variadic tuple elements with intersections containing InstantiableNonPrimitive - #64239

Merged
Jake Bailey (jakebailey) merged 3 commits into
microsoft:mainfrom
Andarist:fix/recursive-variadic-tuple-crash
Nov 18, 2026
Merged

Jake Bailey (jakebailey) merged 3 commits into
microsoft:mainfrom
Andarist:fix/recursive-variadic-tuple-crash

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes #63040
recreates #63128

Copilot AI balanced review requested due to automatic review settings September 11, 2026 08:24
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 11, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix handles the reported intersection case and includes matching regression coverage.

Pull request overview

Prevents recursive variadic tuple normalization from overflowing when intersections contain generic instantiable types.

Changes:

  • Detects generic types within unions or intersections.
  • Adds regression coverage for issue #63040 and expected baselines.
File summaries
File Description
tsc/internal/checker/checker.go Updates tuple normalization and adds a contained-type helper.
tsc/testdata/tests/cases/compiler/recursiveConditionalCrash5.ts Adds the crash regression case.
tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash5.errors.txt Records the expected diagnostic.
tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash5.types Records inferred types.
tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash5.symbols Records resolved symbols.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

return f(t)
}

func someContainedType(t *Type, f func(*Type) bool) bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, we don't have this helper already?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I think I was adding this at least twice in various PRs though but they didn't get in at the time :P

@jakebailey

Copy link
Copy Markdown
Member

This fixes something I found in #65064. Here's a test case I think should be added:

type Spread<T extends readonly unknown[]> = [0, ...(T & readonly unknown[])];
type A = Spread<[1, 2]>;

type Tagged<T extends unknown[]> = [0, ...(T & { tag?: 1 })];
type B = Tagged<string[]>;

declare function f<T extends unknown[]>(x: T): [0, ...(T & { tag?: 1 })];
const c = f([1, "a"] as [1, "a"]);

On main these all come out as [0, ...unknown[]]. With this PR they're [0, ...(1 | 2)[]], [0, ...string[]], and [0, ...("a" | 1)[]].

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 18, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Nov 18, 2026
Merged via the queue into microsoft:main with commit a2fcfde Nov 18, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

RangeError: Maximum call stack size exceeded in getTypeFromTypeNode when resolving recursive tuple rest with intersection

4 participants