microsoft / microsoft/TypeScript
noImplicitThis codefix should account for static functions
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Search Terms
codefix static this noImplicitThis
Suggestion
If a function is used as the initializer of a static property declaration, should the type of its this added by the --noImplicitThis codefix include typeof?
See discussion in #31138.
Use Cases
Static methods are arguably more likely to be called with the static class as their this scope in common practice. This would more accurately reflect that behavior.
Examples
const returnThisMember = function ([| |]) {
return this.member;
}
class Container {
member = "sample";
static returnThisMember = returnThisMember;
};
Right now [| |] just becomes this: Container.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
noImplicitThis codefix と #31138 の議論から始め、静的プロパティの初期化子として使用される関数がどのように this 型を受け取るのかを追ってください。Container の例を使って、提案された型が静的なクラススコープを考慮していることを、必要に応じて typeof も含めて確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100