Skip to content

Forced symbol for the file with JSDoc @name returns an error that it does not exist #231

Open
@lukaszpolowczyk

Description

@lukaszpolowczyk

It is the code from the documentation (https://jsdoc.app/tags-name.html):

// @ts-check
/**
 * @name highlightSearchTerm
 * @function
 * @global
 * @param {string} term - The search term to highlight.
 */
 eval("window.highlightSearchTerm = function(term) {};")

 window.highlightSearchTerm("");

But it still returns an error:

Property 'highlightSearchTerm' does not exist on type 'Window & typeof globalThis'.ts(2339)

Live inline example - https://codesandbox.io/s/jsdoc-name-test-1u224k?file=/src/index.js (locally in VSCode there is the same error)

QUESTION: Why does @name not work? What should I replace it with?

My target code is supposed to be like this:

// @ts-check
/**
 * @name highlightSearchTerm
 * @function
 * @global
 * @param {string} term - The search term to highlight.
 */

 highlightSearchTerm("");

...because it's a function from another file, it uses in userScript, but so far even the version with window doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions