microsoft / microsoft/TypeScript

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

Open
#55,899 1 comment 0 reactions 1 assignee View on GitHub

@sandersn is already working on this.

Since Sep 28, 2023.

Bug Domain: classes Effort: Casual Help Wanted Rescheduled
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.