Skip to content

jsdoc/require-template doesn't work with a default value for a type parameter #1418

@alexander-akait

Description

@alexander-akait

Expected behavior

No error

Actual behavior

Error

X:X  error  Missing @template T  jsdoc/require-template

If change @template {string | Buffer} [T=string] to @template {string | Buffer} T all works fine.

ESLint Config

{
  "jsdoc/require-template": "error",
}

ESLint sample

/**
 * @template {string | Buffer} [T=string]
 * @typedef {object} Dirent
 * @property {() => boolean} isFile true when is file, otherwise false
 * @property {() => boolean} isDirectory true when is directory, otherwise false
 * @property {() => boolean} isBlockDevice true when is block device, otherwise false
 * @property {() => boolean} isCharacterDevice true when is character device, otherwise false
 * @property {() => boolean} isSymbolicLink true when is symbolic link, otherwise false
 * @property {() => boolean} isFIFO true when is FIFO, otherwise false
 * @property {() => boolean} isSocket true when is socket, otherwise false
 * @property {T} name name
 * @property {string} parentPath path
 * @property {string=} path path
 */

Environment

  • Node version: v22.13.1
  • ESLint version v9.28.0
  • eslint-plugin-jsdoc version: v51.2.2

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions