microsoft / microsoft/TypeScript

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

Aperta
#55,500 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@rbuckton ci sta già lavorando.

Dal 24/8/2023.

Bug Domain: classes Rescheduled
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.