Skip to content

chained generic mixins fail #28594

Open
Open
@prasannavl

Description

@prasannavl

TypeScript Version: 3.2.0-dev.201xxxxx

Search Terms: chained generic mixins

Code

type Constructor<T> = new(...args: any[]) => T;

interface XInterface {
    value: string;
 }

function make<T extends Constructor<any>>(Base: T) {
    return class extends Base implements XInterface {
        value = "Hello!"
    }
}

// Great. Works.
class _X1 extends make(Function) { hello() { this.value; }}

type _T1 = Constructor<HTMLElement>;

// Oops. But changing `make(Base)`, to `make(Base as _T1)` works perfectly, 
// which makes no sense.
function make2<T extends _T1>(Base: T) {
    return class extends make(Base) { }
}

Expected behavior:
Compile.

Actual behavior:
Type '{ new (...args: any[]): make.(Anonymous class); prototype: make.(Anonymous class); } & T' is not a constructor function type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions