Skip to content

String literal overload does not provide completion when undefined or void parameter present  #14333

Closed
@NoelAbrahams

Description

@NoelAbrahams

TypeScript Version: 2.2

Code

type Options = {
        text: string;
};

// Demonstrates fail with undefined
interface Foo {
    foo(kind: 'Bar', state?: undefined): void;
    foo(kind: 'Foo', state?: Options): void;
}

let f: Foo;
f.foo('Foo', { t }) // No completion offered for 't'

// Demonstrates fail with void
interface Foo2 {
    foo(kind: 'Bar', state?: void): void;
    foo(kind: 'Foo', state?: Options): void;
}

let ff: Foo2;
ff.foo('Foo', { t  }) // No completion here either

// Demonstrates success after changing order of overloads
interface Foo3 {
    foo(kind: 'Foo', state?: Options): void;
    foo(kind: 'Bar', state?: undefined): void;
}

let fff: Foo3;
fff.foo('Foo', { t }) // Okay: completion offered for 't'

Expected behavior:

Completion for the property "text" where it says "No completion offered for 't'"

Actual behavior:

There is no completion for "text" when "t" is typed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions