Incorrect error reported when using `class extends null` and re-opening interface

未关闭
#55,500 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@rbuckton 已经在做这个了。

开始于 2023年8月24日。

评估

这个 Issue 还没有评估数据。

描述

Bug Domain: classes Rescheduled
🔎 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

https://www.typescriptlang.org/play?lib=true&ts=5.1.6#code/JYOwLgpgTgZghgYwgAgEJwM4oN4CgC+uuCANphsgMLIQAekIAJhSAK4knJ7I-IID2IDGCisEYflAAUASi65eyQoVCRYiFNToNmaTDnxA

💻 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.
主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 19 小时
30 天内合并 PR
117

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/TypeScript 的其他 Issue

查看 microsoft/TypeScript 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。