Skip to content

Incorrect error reported when using class extends null and re-opening interfaceΒ #55500

Open

Description

@rbuckton

πŸ”Ž 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.

Activity

  1. added
    Fix Available
    on Feb 9, 2024
  2. added
    Rescheduled
    on Mar 4, 2024
  3. added
    Domain: classes
    on Oct 16, 2025
  4. removed
    Fix Available
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDomain: classesRescheduled

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions