Skip to content

@typedef can access function type parameters #20832

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

Closed
ghost opened this issue Dec 20, 2017 · 0 comments · Fixed by #24204
Closed

@typedef can access function type parameters #20832

ghost opened this issue Dec 20, 2017 · 0 comments · Fixed by #24204
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@ghost
Copy link

ghost commented Dec 20, 2017

TypeScript Version: 2.7.0-dev.20171220

Code

/** @typedef {U} T */

/**
 * @template U
 * @param {U} x
 * @return {T}
 */
function f(x) {
    return x;
}

/** @type T */
const x = 3;

Expected behavior:

We shouldn't be able to access U in the definition for T. Doing so leads to strange behavior later on.

Actual behavior:

We can. But then we can't use T anywhere because it leaks U.

@ghost ghost added Bug A bug in TypeScript Salsa labels Dec 20, 2017
@mhegazy mhegazy added this to the TypeScript 2.9 milestone Apr 12, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 17, 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 Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants