microsoft / microsoft/TypeScript
JSDoc comment on JS class property isn't inherited when derived class also initializes it
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
When a JS class extends another, and members are overridden in the constructor, they will lose all of their documentation - even if they are compatible values.
🔎 Search Terms
jsdoc class es6 js extends
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about JS / JSDoc
⏯ Playground Link
Playground link with relevant code
Note the type info when hovering over this.a in Derived's constructor, or a in the bottom line.
💻 Code
class Base
{
constructor()
{
/** I am an integer! */
this.a = 100;
}
}
class Derived extends Base
{
constructor()
{
super();
this.a = 50;
// hover over this.a above to see the issue
}
}
// hover over a to see the issue as well
new Derived().a
🙁 Actual behavior
a was overridden by Derived, even though it is a type match.
🙂 Expected behavior
While I can see the usefulness here if a was a different/incompatible type entirely, I would rather an error occur on, for instance, this.a = "str"; because a is a number, not a string, and for it to inherit the JSDoc properly. It seems like this.xxx in a constructor declares a new variable, even if it inherits one.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground から始め、Derived の this.a と new Derived().a に対するホバー動作を再現してください。JavaScript のクラスコンストラクターと JSDoc コメントがどのように解釈されるかを追跡し、互換性のあるオーバーライドではドキュメントが保持され、互換性のない代入が診断されることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100