Skip to content

Consider base class from extended generic type #2441

Closed
@stephanedr

Description

@stephanedr

Sorry if this has already been submitted (was not able to find).
It would be great if TS could consider the base class from an extended generic type.

interface Type<T> {
    new (...args: any[]): T;
}

function ok(type: Type<Error>) {
    return type == RangeError;
}

function fail<T extends Error>(type: Type<T>) {
    return type == RangeError; // Operator '==' cannot be applied to types 'Type<T>' and 'RangeErrorConstructor'.
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadCanonicalThis issue contains a lengthy and complete description of a particular problem, solution, or designSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions