microsoft / microsoft/TypeScript

Two consecutive variadic elements in the middle part of tuple type can't be recognized

オープン
#62,561 コメント 3 件 リアクション 0 件 担当者 1 名 GitHub で見る

@ahejlsberg がすでに取り組んでいます。

2025年10月8日 から。

Needs Investigation
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

### 🔎 Search Terms

tuple, variadic element

### 🕗 Version & Regression Information
Since 4.0.5

### ⏯ Playground Link

https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMAPAFUQUwB5U2AEwGdFwBrMOAdzAG0BdAGkQDUtd9jSwLq76AfAApsALloAjOHAA2mAIZhmAOlUsVqtE0Srl8gE4BzIqJYBKRAG8AUIjt39mKCH1JsAbmsBfRNesQEIihEeUQAXmQhWih9EExmACZmACIJZOYYuO0ARhT5ZMQzd0QAehKAUX19OH1mHAAHTGhMAkQEkKMQAFt8KCJmCRBgwzhggGYgA

### 💻 Code

```ts
function f(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

https://stackoverflow.com/posts/79784883/edit

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。