Skip to content

Declaration emit for function parameter type references incorrect type alias #12343

@vsiao

Description

@vsiao

TypeScript Version: 2.0.10 (broken since 2.0.2).

Code

export type Foo<A, B> = A | B;
export type Bar<T> = Foo<number, T>;

export const f = <T>(bar: Bar<T>) => {
    return true;
};

Expected behavior:
tsc --declaration bar.ts should emit the following bar.d.ts:

export declare type Foo<A, B> = A | B;
export declare type Bar<T> = Foo<number, T>;
export declare const f: <T>(bar: Bar<T>) => boolean;

NB: 2.0.0 emits <T>(bar: number | T) => boolean, which is acceptable too.

Actual behavior:

export declare type Foo<A, B> = A | B;
export declare type Bar<T> = Foo<number, T>;
export declare const f: <T>(bar: Foo<T>) => boolean; 
// TS2314: Generic type 'Foo' requires 2 type argument(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions