BeyondCodeBootcamp / js-with-types-jsdoc-tsc-starter

A simple, but non-trivial example of getting the most from JSDoc + tsserver (Type Linting without TypeScript)
Mozilla Public License 2.0
17 stars 1 forks source link

Bug in tsc: can't use `@function ...` (must use `@callback ...`) #7

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

See https://github.com/microsoft/TypeScript/issues/50274

❌ Invalid for tsc: @typedef {Function}

/**
 * @typedef {Function} PersonGreet
 * @param {String} name - other's name
 * @returns {String} - the greeting
 */
/**
 * @function PersonGreet
 * @param {String} name - other's name
 * @returns {String} - the greeting
 */

⚠️ Workaround: @callback

It's confusing, but it's our option.

/**
 * @callback PersonGreet
 * @param {String} name - other's name
 * @returns {String} - the greeting
 */