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

貢獻者指南