microsoft / microsoft/TypeScript
Issues with JSDoc private and protected
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
🔎 Search Terms
JSDoc access modifier
🕗 Version & Regression Information
- This changed in version
v3.8probably because JSDoc accessibility modifiers were introduced; that is to say: it never worked
⏯ Playground Link
Playground Link: Provided
💻 Code
/** @class */
function Legacy () {
/** @protected */
this.prop = 1; // should not be an error
this.doStuff(); // should not be an error
}
/** @private */
Legacy.prototype.doStuff = function () {
this.prop; // should not be an error
this.doStuff(); // should not be an error
}
class C {
/** @protected */
prop = 1;
}
/** @this {C} */
function fn() {
this.prop; // the equivalent works in TS
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"checkJs": true,
"allowJs": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": 2,
"target": "ES2017",
"jsx": "React",
"module": "ESNext"
}
}
🙁 Actual behavior
Using legacy class syntax and so-called "assignment declarations" don't recognize that the properties are actually accessed inside the class. That's because the checker logic only looks for real ClassLikeDeclaration Nodes.
Note that @readonly correctly recognizes function Legacy as the constructor and allows assignment there.
Using a protected member in a function with explicit this-parameter works in TS, but doesn't when using @this in JS.
🙂 Expected behavior
No errors in the code.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された TypeScript Playground の再現から始め、checkJs 下でレガシーコンストラクター、代入宣言、@this のケースを比較します。レポートで説明されている checker の動作を、対照的な @readonly の動作も含めて追跡します。提供されたコードがエラーを生成せず、期待される protected および private のアクセスチェックを維持できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 38/100