jsdoc.github.io icon indicating copy to clipboard operation
jsdoc.github.io copied to clipboard

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

Open lukaszpolowczyk opened this issue 3 years ago • 0 comments

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.

lukaszpolowczyk avatar May 15 '22 01:05 lukaszpolowczyk