Skip to content

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

@kennytm

Description

@kennytm

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

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions