reject-function-type

October 14, 2025 ยท View on GitHub

reject-function-type

Reports use of Function type within JSDoc tag types.

Contexteverywhere
Tagsaugments, class, constant, enum, implements, member, module, namespace, param, property, returns, throws, type, typedef, yields
Aliasesconstructor, const, extends, var, arg, argument, prop, return, exception, yield
Closure-onlypackage, private, protected, public, static
Recommendedtrue
Settingsmode
Options

Failing examples

The following patterns are considered problems:

/**
 * @param {Function} fooBar
 */
function quux (fooBar) {
  console.log(fooBar(3));
}
// Message: Prefer a more specific type to `Function`

/**
 * @param {string|Array<Function>} abc
 */
function buzz (abc) {}
// Message: Prefer a more specific type to `Function`

Passing examples

The following patterns are not considered problems:

/**
 * @param {SomeType} abc
 */
function quux (abc) {}

// To avoid referencing a generic Function, define a callback
//   with its inputs/outputs and a name.
/**
 * @callback          FOOBAR
 * @param    {number} baz
 * @return   {number}
 */


// Then reference the callback name as the type.
/**
 * @param {FOOBAR} fooBar
 */
function quux (fooBar) {
  console.log(fooBar(3));
}

/**
 * @param {string|Array<FOOBAR>} abc
 */
function buzz (abc) {}