Skip to content

Inconsistent lookup/resolution for typeof in JSDoc in references search #61959

Open
@DanielRosenwasser

Description

@DanielRosenwasser
/**
 * @template T
 * @param {T} a
 * @return {typeof a}
 */
function f(a) {
    return a;
}

Today, this gives the following error (playground link):

 * @return {typeof a}
                   ~
error: Cannot find name 'a'.

However, if you add an outer declaration of a (playground link):

let a = 123;

/**
 * @template T
 * @param {T} a
 * @return {typeof a}
 */
function f(a) {
    return a;
}

typeof a "correctly" resolves to the outer a (and you can see so with the error), but go-to-definition and find-all-references resolve locally to the parameter, not the outer local.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyDomain: Symbol NavigationRelates to go-to-definition, find-all-references, highlighting/occurrences.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions