microsoft / microsoft/TypeScript
'this' not inferred for immediately invoked .bind()/.call()/.apply()
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
🔎 Search Terms
function type inferrence, function apply function, function call function
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about type inference
⏯ Playground Link
Playground link with relevant code
💻 Code
let f2 = function(this: number[]) {
console.log(this)
}.bind([1, 2, 3]);
// ^^ works fine
let f1 = function() {
console.log(this)
// ^^ 'this' implicitly has type 'any' because it does not have a type annotation.
}.bind([1, 2, 3]);
🙁 Actual behavior
Compiler shows an error: "'this' implicitly has type 'any' because it does not have a type annotation."
🙂 Expected behavior
The type of this to be correctly infered from the bind, call or apply call.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground の再現例から始め、即時に呼び出される bind、call、apply を使って、型注釈ありの関数と型注釈なしの関数を比較します。これらの呼び出しに対するコンパイラーの this 推論の扱いを追跡します。型注釈なしの例が implicit-any エラーなしでバインドされた配列型を推論し、既存の動作を維持できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100