Skip to content

Can't extend WeakMap in type-checked JS filesΒ #56664

Open

Description

πŸ”Ž Search Terms

WeakMap constructors return type JSDoc

πŸ•— Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play?filetype=js#code/MYGwhgzhAEDCD2J4CcCyYAO0CmAPALtgHYAmMA6tmANbpYDeAUNNMPERPsgK7D4oAKAJTQmLFhG4ZsyYQG5m0AL6MlQA

πŸ’» Code

class ColorMap extends WeakMap {
  constructor() {
    super();
  }
}

πŸ™ Actual behavior

color.js(1,24): error TS2510: Base constructors must all have the same return type.

I tried a few different workarounds, like adding @template generic params, or forcing types using @type JSDoc, but nothing seems to work.

πŸ™‚ Expected behavior

No error.

Additional information about the issue

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFix AvailableA PR has been opened for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions