Microsoft/TypeScript

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

Open

#55,899 建立於 2023年9月28日

在 GitHub 查看
 (1 留言) (0 反應) (1 負責人)TypeScript (6,726 fork)batch import
BugDomain: classesEffort: CasualFix AvailableHelp WantedRescheduled

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 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
    }
}

貢獻者指南