ts-prefer-function-type

October 9, 2025 ยท View on GitHub

ts-prefer-function-type

Inspired by typescript-eslint's prefer-function-type rule.

Chooses the more succinct function property over a call signature if there are no other properties on the signature.

Options

A single options object has the following properties.

enableFixer

Whether to enable the fixer or not

Contexteverywhere
Tags``
Recommendedfalse
Settings
OptionsenableFixer

Failing examples

The following patterns are considered problems:

/**
 * @param {{
 *   (arg: string): void;
 * }} someName
 */
// Message: Call signature found; function type preferred.

/**
 * @param {{
 *   (arg: string): void;
 * }} someName
 */
// "jsdoc/ts-prefer-function-type": ["error"|"warn", {"enableFixer":false}]
// Message: Call signature found; function type preferred.

/**
 * @param {(string | {
 *   (arg: string): void;
 * })} someName
 */
// Message: Call signature found; function type preferred.

Passing examples

The following patterns are not considered problems:

/**
 * @param {() => number} someName
 */

/**
 * @param {{
 *   (arg: string): void;
 *   abc: number;
 * }} someName
 */

/**
 * @param {{
 *   (data: string): number;
 *   (id: number): string;
 * }} someName
 */

/**
 * @param {BadType<} someName
 */