microsoft / microsoft/TypeScript
Accessing protected computed property does not produce a compiler error
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔎 Search Terms
protected computed no error bug
🕗 Version & Regression Information
This is the behavior in every version I tried (v3.3.3333, v4.0.5, v5.7.3), and I reviewed the FAQ for entries about Common "Bugs" That Aren't Bugs
⏯ Playground Link
💻 Code
declare class Foo {
protected readonly baz = 42
}
declare class Bar {
readonly foo: Foo
}
declare const bar: Bar
// @ts-expect-error
console.log(bar.foo["baz"].toFixed(2))
🙁 Actual behavior
- (without
// @ts-expect-error): No errors - (with
// @ts-expect-error): Compiler errorUnused '@ts-expect-error' directive
🙂 Expected behavior
- (without
// @ts-expect-error): Compiler errorProperty […] is protected and only accessible within class 'Foo' and its subclasses - (with
// @ts-expect-error): No errors
Additional information about the issue
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された Foo、Bar、およびブラケットアクセスの例を使って、TypeScript Playground のリンクにある動作を再現します。まず、インデックスアクセスを介した protected プロパティへのアクセスをコンパイラがどのように処理するかを追跡し、次に期待される診断のカバレッジを追加して、@ts-expect-error ディレクティブが消費されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100