microsoft / microsoft/TypeScript
Two consecutive variadic elements in the middle part of tuple type can't be recognized
@ahejlsberg is already working on this.
Since Oct 8, 2025.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
🔎 Search Terms
tuple, variadic element
🕗 Version & Regression Information
Since 4.0.5
⏯ Playground Link
💻 Code
function f<U extends unknown[], V extends unknown[]>(x:[boolean, ...V, ...U], ...args:V) {
return x;
}
const a = f([true, 2, "b", true], 1, "a" ); //Error, expected 2 arguments, but got 3
🙁 Actual behavior
Compiler sees error
🙂 Expected behavior
No error, because as https://github.com/microsoft/TypeScript/pull/39094 states
If the middle part of T is exactly two variadic elements ...A and ...B, and an implied arity exists for A, infer from a tuple consisting of the initial middle part of S to A and from a tuple consisting of the remaining middle part of S to B, where the length of the initial middle part corresponds to the implied arity for A.
As I understand the middle part of S is 2, "b", true and in the middle part of T we have ...V, ...U then 2, "b" is ...V and true is ...U.
Additional information about the issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.