Microsoft/TypeScript

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

开放

#55,899 创建于 2023年9月28日

 (1 条评论) (0 个反应) (1 位负责人)TypeScript (13,395 个派生)batch import
BugDomain: classesEffort: CasualHelp WantedRescheduled

仓库指标

星标
 (108,860 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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
    }
}

贡献者指南