microsoft / microsoft/TypeScript
Checking JS types does not accept @implements or @augments on constructor functions
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.9.5 (also tested on 3.9.3 initially)
Search Terms: @implements, jsdoc
Code
/**
* @param {string} name
* @implements {EventTarget}
* @constructor
*/
function Foo (name) {
this.name = name
}
/**
* @param {string} type
* @param {EventListenerOrEventListenerObject} listener
* @param {boolean | AddEventListenerOptions} [options]
*/
Foo.prototype.addEventListener = function (type, listener, options) {}
Then run tsc --noEmit --checkJS --allowJS reproducer.js
Expected behavior:
According to https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#constructor-functions-are-equivalent-to-classes, constructor functions are treated like classes. So using @implements or @augments on them should be possible. It used to work in the past.
Actual behavior:
reproducer.js:6:10 - error TS8022: JSDoc '@implements' is not attached to a class.
6 function Foo (name) {
~~~
Found 1 error.
Playground Link: I was not able to reproduce this in the playground (but it does not have the latest 3.9 versions available)
Related Issues:
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
reproducer.js の例から始め、影響を受ける TypeScript バージョンで tsc --noEmit --checkJS --allowJS reproducer.js を実行します。コンストラクター関数に対する JSDoc @implements と @augments の処理を追跡します。アノテーションが TS8022 なしで受け入れられ、既存の JavaScript チェックが引き続き有効であれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100