Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaration emit is incorrect when type parameter names collide #16313

Closed
DanielRosenwasser opened this issue Jun 7, 2017 · 1 comment
Closed
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

function f<T>(p: T) {
    let g: <T>(x: T) => typeof p = null as any;
    return g;
}

Calling f(10) will produce something of type <T>(x: T) => number, however, the declaration emit is the following:

declare function f<T>(p: T): <T>(x: T) => T;

But calling that f produces the type <T>(x: T) => T.

@mhegazy mhegazy added the Bug A bug in TypeScript label Jun 7, 2017
@gcnew
Copy link
Contributor

gcnew commented Jun 7, 2017

I'm looking forward for a solution to this issue. It would be a big problem when polymorphic unification gets implemented, because generic parameters must be instantiated with a copy of their type parameters for inference to properly work.

declare function id<X>(x: X): X;
declare function mapPair<A, B, C, D>(
    fx: (a: A) => B,
    fy: (c: C) => D
): (a: A, c: C) => [B, D];

mapPair(id, id) // = mapPair<X, X, X, X>, but should be mapPair<X1, X1, X2, X2>

My newest prototype from #9949 does the instantiation, however the variables remain with the same symbol name. They have different ids, but their textual representation is the same.

@mhegazy mhegazy added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Apr 13, 2018
@mhegazy mhegazy added this to the TypeScript 2.9 milestone Apr 13, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 10, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants