microsoft / microsoft/TypeScript
No error when accessing setter-only properties
オープン
まだ誰も着手していません。
In Discussion
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
"setter only", "setter-only"
🕗 Version & Regression Information
- This behavior is present in the current version of TypeScript, 5.4.4
⏯ Playground Link
💻 Code
class Foo {
set bar(baz: string) { }
}
const foo = new Foo();
const value: string = foo.bar; // This assignment should not be allowed, foo.bar will always be undefined!
🙁 Actual behavior
There is no error reported during type-checking.
🙂 Expected behavior
The type-checking should report an error for the assignment in the last line as foo.bar will always be undefined.
Additional information about the issue
#21759 is related, but that issue proposes a whole new language feature, this issue is solely about the lack of a type error.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている TypeScript Playground から始め、setter のみを持つプロパティへの代入を再現して、現在の型チェックの動作を確認してください。foo.bar の読み取りに関係する type-checker の経路を追跡し、読み取り結果を string に代入するとエラーが報告されることを示すテストカバレッジを追加してください。ただし、#21759 で議論されている別の機能は実装しないでください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100