Equivalent arguments typed with tuples aren't assignable to the same functions with overloads when the same function is recursively referenced
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- compilers
調査の方向性
issue にリンクされている TypeScript Playground の再現から始め、タプル引数の関数とオーバーロードされた関数の間で再帰的な代入可能性がどのように動作するかを調査します。再帰的なシグネチャに対する正しいチェックを維持したまま、示されている代入がエラーなしで成功すれば作業完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug Report
🔎 Search Terms
arguments, overloads, function, tuple
🕗 Version & Regression Information
All versions with support for tuple arguments (upto v4.5.0-dev.20210815).
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about function overloading (there is nothing in the FAQ about tuples)
⏯ Playground Link
Playground link with relevant code
💻 Code
type START = 0
type DATA = 1
type Args<In, Out> =
| [t: START, other: FnWithArgs<Out, In>]
| [t: DATA]
type FnWithArgs<In, Out> = (...args: Args<In, Out>) => void
interface FnWithOverloads<In, Out> {
(t: START, other: FnWithOverloads<Out, In>): void;
(t: DATA): void;
}
declare const withArgs: FnWithArgs<1, 2>
// these should be assignable to one another, but aren't:
const assertion: FnWithOverloads<1, 2> = withArgs
🙁 Actual behavior
Two types that should be functionally equivalent aren't assignable to one another:
Type 'FnWithArgs<1, 2>' is not assignable to type 'FnWithOverloads<1, 2>'.
Types of parameters 'args' and 't' are incompatible.
Type '[t: 0, other: FnWithOverloads<2, 1>]' is not assignable to type 'Args<1, 2>'.
Type '[t: 0, other: FnWithOverloads<2, 1>]' is not assignable to type '[t: 0, other: FnWithArgs<2, 1>]'.
Type at position 1 in source is not compatible with type at position 1 in target.
Type 'FnWithOverloads<2, 1>' is not assignable to type 'FnWithArgs<2, 1>'.
Types of parameters 't' and 'args' are incompatible.
Type 'Args<2, 1>' is not assignable to type '[t: 0, other: FnWithOverloads<1, 2>]'.
Type '[t: 1]' is not assignable to type '[t: 0, other: FnWithOverloads<1, 2>]'.
Source has 1 element(s) but target requires 2.
I've tried simplifying the example, and this issue doesn't seem to occur when the parameters of the function don't reference themselves in their signature.
🙂 Expected behavior
No error, types should be assignable to one another.
Related issues
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/TypeScript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/TypeScript#64322 · コメント 2 件 · リアクション 1 件 · 担当者 2 名 ·
-
Possible Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/TypeScript#64278 · コメント 1 件 · リアクション 1 件 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/TypeScript#64118 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoft/TypeScript#64094 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/TypeScript#63959 · コメント 5 件 ·
microsoft/TypeScript の issue をすべて見る
似ている issue
-
optimization optimization:agents-md-curator
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
githubnext/gh-aw-cao#13143 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
blinklabs-io/bursa#904 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · コメント 2 件 ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100