Skip to content

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

Closed
@sandersn

Description

@sandersn

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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationFixedA PR has been merged for this issuecheckJsRelates to checking JavaScript using TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions