microsoft / microsoft/TypeScript
Cannot annotate a field in constructor as null using jsdoc @type
オープン
まだ誰も着手していません。
Bug
Domain: JSDoc
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 4.0.2
Search Terms: jsdoc null type implicit any
Code
class Foo {
constructor () {
/** @type {number} */
this.bar = 42
/** @type {null} */
this.foo = null
}
}
Expected behavior:
Expected to have a class with two fields, bar of type number & foo of type null
I don't know why it doesn't understand null; using string | null works fine.
Actual behavior: Member 'foo' implicitly has an 'any' type.
Related Issues:
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground の JavaScript 例を再現し、@type {null} フィールドと動作する string | null 形式を比較します。コンストラクターで値が代入されるクラスフィールドに対して、JSDoc @type アノテーションがどのように処理されるかを追跡します。完了条件は、null フィールドが null として推論され、暗黙の any エラーが発生しないことです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100