Skip to content

Cannot extend generic type with a mixin #21710

@dpogue

Description

@dpogue

There appears to be no way to extend a generic type using in a mixin-style pattern, because the type arguments cannot be passed through.

TypeScript Version: 2.7.1

Search Terms: base constructor, type arguments

Code

function subclass<T>(klasstype : T) : T {
  // This is our mixin, but for demo purposes just return the class
  return klasstype;
}

class DerivedPromise<T> extends subclass(Promise) { }

Expected behavior:
A class that extends Promise.

Actual behavior:
TS2508: No base constructor has the specified number of type arguments.

Playground Link:
Here

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions