Skip to content

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

@zombie

Description

@zombie

🔎 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: classesBehavior of various `class` constructs, e.g. mixins or base classesFix 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