Skip to content

Instantiation of intersections not checked for abstract restriction #4559

@sophiajt

Description

@sophiajt

Say I wanted to create two partial classes, merge them together, and instantiate the result:

abstract class Left {
    left() { return this.right(); }
    abstract right(): number; 
}

abstract class Right {
    abstract left() : number;
    rright(){ return this.left(); }     
}

function merge<A, B>(a: A, b: B) : A & B { return undefined; }

var ab = new(merge(Left, Right));

We currently don't catch the error that we're new'ing something that is abstract. Notice the 'rright' in the Right, so that intersection can't really satisfy the abstract requirements from Left.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptWon't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions