Skip to content

@typedef can access function type parameters #20832

Closed
@ghost

Description

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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions