microsoft / microsoft/TypeScript
Unable to mark JS functions as not being constructors (TS80002)
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
TS80002 ("This constructor function may be turned to a class declaration") is a useful tool, but, it often breaks syntax coloring and classification of functions for things like out-of-line event handlers. There seems to be no way to mark a function as "not a constructor" (would the @function JSDoc hint maybe serve this purpose?)
🔎 Search Terms
jsdoc typescript constructor ts80002
🕗 Version & Regression Information
- This behavior was introduced after 3.6.2 at some point, and I reviewed the FAQ for entries about TS80002.
⏯ Playground Link
Playground link with relevant code
💻 Code
/**
* @this {HTMLElement}
* @param {MouseEvent} e
*/
function test(e)
{
this.textContent = '500';
}
document.addEventListener('click', test);
🙁 Actual behavior
TypeScript marks the function test as a constructor for a type. As a consequence, too, VSCode marks it as a type, and not a function, which is confusing for navigation purposes.
🙂 Expected behavior
TypeScript should be able to detect that with a @this hint (or @function perhaps?) that this isn't a constructor.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた TypeScript Playground で JavaScript と TS80002 を使って動作を再現し、その後、@this および @function の JSDoc ヒントがコンストラクターの検出にどのような影響を与えるかを調査する。サポートされているアノテーションまたは推論経路によって関数がコンストラクターとして分類されるのを防ぎ、エディターでのナビゲーションに期待される関数の分類が復元されれば完了とする。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers, devtools
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100