Skip to content

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

Closed

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).

Activity

  1. vsiao commented on Nov 18, 2016

    @vsiao
    Author

    ah, sorry—looks like this was fixed for 2.1: #11931

  2. vsiao commented on Nov 18, 2016

    @vsiao
    Author

    Looks good in nightly, but still broken in 2.1.1 (RC). Mohamed Hegazy (@mhegazy) can you confirm which release the fix will be in?

  3. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions