Skip to content

Code completion doesn't work when using function overloading #8005

Closed
@Lenne231

Description

@Lenne231

TypeScript Version:

1.8.0

Code

interface A {
    name: string;
    age: number;
}

interface AExtension {
    name?: string;
    age?: number;
}

interface B {
    key: string;
    value: boolean;
}

interface BExtension {
    key?: string;
    value?: boolean;
}

function extend(base: A, extension: AExtension);
function extend(base: B, extension: BExtension);
function extend<T>(base: T, extension: any) {

}

const b : B = { key: '...', value: true };

extend(b, { key: '' });

Expected behavior:
Code completion for second parameter of extend shows properties of BExtension.

Actual behavior:
Code completion for second parameter of extend shows properties of AExtension.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelates to the public API for TypeScriptFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions