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

オープン
#55,500 コメント 0 件 リアクション 0 件 担当者 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時間
マージ済み PR(30日)
117

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/TypeScript のほかの issue

microsoft/TypeScript の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。