Skip to content

typedef tag is able to resolve type variables declared in same jsdoc comment #23740

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
sandersn opened this issue Apr 27, 2018 · 1 comment · Fixed by #23947
Closed

typedef tag is able to resolve type variables declared in same jsdoc comment #23740

sandersn opened this issue Apr 27, 2018 · 1 comment · Fixed by #23947
Assignees
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

Typedef tags are supposed to be visible in the parent scope of the jsdoc comment they are attached to. That also means that they should not be able to see things in the same jsdoc comment that are supposed to be visible in the child scope, such as @template.

/**
 * @template T
 * @typedef {T} N
 */
class C {
    /** @param {N} n */
    m(n) {
        n
    }
}
/** @type {N} */
var y;

Expected behavior:
n: T and y: unknown with an error on @type {N} "Cannot resolve name 'N'."

Actual behavior:
n: T and y: T and no error.

@mhegazy mhegazy added Bug A bug in TypeScript Salsa Domain: JSDoc Relates to JSDoc parsing and type generation checkJs Relates to checking JavaScript using TypeScript labels Apr 27, 2018
@mhegazy mhegazy added this to the TypeScript 2.9 milestone Apr 27, 2018
@sandersn
Copy link
Member Author

sandersn commented May 7, 2018

Fixed in #23947

@sandersn sandersn added the Fixed A PR has been merged for this issue label May 7, 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 checkJs Relates to checking JavaScript using TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants