Microsoft/TypeScript

Indexing/element access on `super` avoids instance property checks

オープン

#55,899 opened on 2023/09/28

 (1 件のコメント) (0 件のリアクション) (1 人の担当者)TypeScript (13,395 件のフォーク)batch import
BugDomain: classesEffort: CasualHelp WantedRescheduled

Repository metrics

Stars
 (108,860 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Discovered in conversation at https://github.com/microsoft/TypeScript/pull/55892#discussion_r1339658106

class C {
    yadda = () => {};
}

class D extends C {
    badda() {
        super["yadda"]();
    }
}

new D().badda()

Currently there is no error for this code; however, if you switched it to a property access, you'd get the error introduced at https://github.com/microsoft/TypeScript/pull/54056.

class C {
    yadda = () => {};
}

class D extends C {
    badda() {
        super.yadda(); // ❌ errors, as expected
    }
}

コントリビューターガイド