Skip to content

Overloads with single string literal type gives assignability errors #6732

Closed
@zhengbli

Description

@zhengbli

Sample code:

interface Base {
    foo(p1: string, p2: string): void;
}

interface T extends Base {
    foo(p1: "p1" | "p2", p2: string): void; // Pass
}

interface T2 extends Base {
    foo(p1: "p3", p2: string): void; // Error: Specialized overload signature is not assignable to any non-specialized signature
}

Maybe related: #6272, however this seems stricter instead of looser

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions