Skip to content

Normalize NoInferred tuple types in rest/spread positions - #4597

Open
Andarist wants to merge 3 commits into
microsoft:mainfrom
Andarist:fix/rest-no-infer
Open

Normalize NoInferred tuple types in rest/spread positions#4597
Andarist wants to merge 3 commits into
microsoft:mainfrom
Andarist:fix/rest-no-infer

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings July 10, 2026 21:52

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.

Pull request overview

Adds coverage and a checker-side normalization to ensure NoInfer-wrapped tuple types behave consistently when used in rest/spread positions (addressing microsoft/TypeScript#59668 and #63627).

Changes:

  • Normalize NoInfer<T> when it appears in rest parameters and variadic tuple elements, so tuple spreads are handled predictably.
  • Add new conformance tests for NoInfer in rest/spread scenarios and commit the corresponding reference baselines.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/checker/checker.go Adds normalizeNoInferSpread and applies it when computing types for rest parameters and variadic tuple elements.
testdata/tests/cases/conformance/types/typeRelationships/typeInference/noInferRestSpread1.ts New test cases covering contextual typing and error behavior with NoInfer in rest parameters.
testdata/tests/cases/conformance/types/typeRelationships/typeInference/noInferRestSpread2.ts New test cases covering tuple spread/rest normalization for NoInfer (including empty tuple rest).
testdata/baselines/reference/conformance/noInferRestSpread1.types Reference type baseline for the new noInferRestSpread1 test.
testdata/baselines/reference/conformance/noInferRestSpread1.symbols Reference symbols baseline for the new noInferRestSpread1 test.
testdata/baselines/reference/conformance/noInferRestSpread1.errors.txt Reference error baseline for the expected failure in noInferRestSpread1.
testdata/baselines/reference/conformance/noInferRestSpread2.types Reference type baseline for the new noInferRestSpread2 test.
testdata/baselines/reference/conformance/noInferRestSpread2.symbols Reference symbols baseline for the new noInferRestSpread2 test.

Comment on lines +23279 to +23282
return c.mapType(t.AsSubstitutionType().baseType, func(element *Type) *Type {
if !isTupleType(element) {
return c.getNoInferType(t)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants