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

JSDoc @template: Generics in return type of returned function is not evaluated. #15177

Closed
kennytm opened this issue Apr 13, 2017 · 2 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@kennytm
Copy link

kennytm commented Apr 13, 2017

TypeScript Version: 2.2.2 (VSCode 1.11.1 on macOS 10.12.4)

Code

// JavaScript.
/**
 * @param {T} a
 * @returns {function(): T}
 * @template T
 */
function g(a) {
    return () => a;
}

let h = g(1)();

Expected behavior: The type of h is inferred as number.

Actual behavior: The type of h is inferred as T...?

screenshot_2017-04-13 21 57 20_ia6bpj

@kennytm kennytm changed the title JSDoc @template: Generates in return type of returned function is not evaluated. JSDoc @template: Generics in return type of returned function is not evaluated. Apr 13, 2017
@mhegazy mhegazy added the Bug A bug in TypeScript label Apr 19, 2017
@mhegazy mhegazy added the Salsa label Apr 19, 2017
@mhegazy mhegazy added this to the TypeScript 2.4 milestone Apr 19, 2017
@sandersn sandersn added this to Not started in Rolling Work Tracking May 16, 2017
@sandersn sandersn moved this from Not started to In Progress in Rolling Work Tracking Jun 6, 2017
@sandersn
Copy link
Member

sandersn commented Jun 12, 2017

When we check whether a type parameter is in scope, the code currently only checks for Typescript type parameters, not for @template tags in the JSDoc. Since the compiler doesn't know T is in scope for instantiation, it just leaves it instead of mapping it to number. I'll have a fix up shortly.

@sandersn sandersn added the Fixed A PR has been merged for this issue label Jun 12, 2017
@sandersn
Copy link
Member

Fix is up at #16463

@sandersn sandersn moved this from In Progress to Done in Rolling Work Tracking Jun 12, 2017
@sandersn sandersn removed this from Done in Rolling Work Tracking Jun 13, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants