Skip to content

allowJs/JsDoc: Extending classes with template argument #25362

@sokra

Description

@sokra

TypeScript Version: 3.0.0-dev.20180630

Search Terms:
TS2510 "Base constructors must all have the same return type" allowJs

Code

/**
 * @extends {Set<number>}
 */
class MySet extends Set {}

var x = new MySet();
for (const n of x) {
  console.log(n);
}

tsc file.js --allowJs --checkJs --noEmit --lib es2017

Expected behavior:

It should compile fine and infer the type of n to number.

Actual behavior:

It errors with:

file.js:4:21 - error TS2510: Base constructors must all have the same return type.

class MySet extends Set {}

but at least infers n to number.

Playground Link:
Playground doesn't support allowJs

Related Issues:
#23551 similar error message, also allowJs, but not using @extends

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions