microsoft / microsoft/TypeScript

Variadic tuple constraint incoherent ?

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

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

2020年7月23日 から。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

TypeScript Version: 4.0.0-dev.20200722

Search Terms:
Variadic tuple
Variadic tuple constraint

Code

type A<GArgs extends [number, string, ...any[]]> = true;
type B<GArgs extends [string, ...any[]]> = A<[number, ...GArgs]>; // ERROR
type C = A<[number, ...[string, ...any[]]]>; // OK

Actual / Expected behavior:

On the type B we get an error:

TS2344: Type '[number, ...GArgs]' does not satisfy the constraint '[number, string, ...any[]]'.   Element at index 1 is variadic in one type but not in the other

Sounds incorrect because on B, GArgs is properly shaped to be just like in C

Playground Link

Related Issues:

The variadic issues are a big jungle, and I was not able to find any related issue (but probably some exists?)

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

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

はじめの一歩

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

評価

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

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

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