microsoft / microsoft/TypeScript

Protected nested classes

オープン
#10,017 コメント 5 件 リアクション 18 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

TypeScript Version: 1.8.9

Code

class Outer {
    protected static Inner = class {}
    private myInner: Outer.Inner;
}

Expected behavior: No errors.

Actual behavior: Compiler error: Cannot find namespace 'Outer'. Line 3, Column 24

Code

class Outer {
    protected static Inner = class {}
    private myInner: Outer.Inner;
}
namespace Outer {}

Expected behavior: No errors.

Actual behavior: Compiler error: Module 'Outer' has no exported member 'Inner'. Line 3, Column 32

Code

export class Outer {
    protected static Inner = class {};
}

export class Child extends Outer {
    static temp = class extends Outer.Inner {}
}

Expected behavior: No errors.

Actual behavior: Compiler error: Property 'Inner' is protected and only accessible within class 'Outer' and its subclasses. Line 6, Column 35


The problem here is that there is no way to define a protected nested class in a way that makes it possible to use in a type declaration. The third example shows why I want to use this: I want a nested class that can only be extended by classes that extend the parent class.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

namespace の回避策とサブクラスの拡張ケースを含め、issue にある 3 つの TypeScript の例を再現してください。コンパイラーがネストされたクラス型と protected static メンバーをどのように解決するかを追跡し、有効な例がエラーなしでコンパイルされる一方で、protected メンバーへのアクセスが引き続き強制されることを示す回帰テストのカバレッジを追加してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。