microsoft / microsoft/TypeScript
Incorrect error reported when using `class extends null` and re-opening interface
@rbuckton is already working on this.
Since Aug 24, 2023.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
class extends null interface
🕗 Version & Regression Information
- This is the behavior in every version I tried (at least up until 3.3, which is the oldest build in the playground).
⏯ Playground Link
💻 Code
interface Base {
}
class C extends null {
constructor() {
}
}
interface C extends Base {}
🙁 Actual behavior
Reports the following error:
Class static side 'typeof C' incorrectly extends base class static side 'null'.
🙂 Expected behavior
No error. inteface Base does not describe the static side of anything, and reopening a class using something like interface C extends Base {} is common practice for shims.
Additional information about the issue
I ran into this when implementing a class that utilizes return override in a constructor when combined with class extends null while experimenting with the Shared Structs origin trial (whose constructors produce objects with a null prototype). Though native extends null has some issues in ES2015+, it still works fine with explicit return override in a constructor in any engine:
class C extends null {
constructor() {
return {};
}
}
new C(); // works just fine.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.