Rules

typed-jsdoc provides two rules that keep your JSDoc accurate and in sync with TypeScript's type inference.

tjd/accurate-jsdoc

Fixable

JSDoc types must match TypeScript's inference. Auto-fixes mismatches.

Bad
/** @returns {string} */
function getValue() {
  return 42;
}
Good
/** @returns {number} */
function getValue() {
  return 42;
}

Options

OptionTypeDefaultDescription
ignorePatternsstring[][]Function names to skip
inferenceConfidencenumber0.5Minimum confidence for auto-fix (0-1)

tjd/no-redundant-jsdoc

Fixable

Remove JSDoc type annotations that don't add information beyond what TypeScript infers.

Bad
/** @type {string} */
const name = String(input);
Good
const name = String(input);

Options

OptionTypeDefaultDescription
keepDescriptionsbooleantruePreserve JSDoc with descriptions
ignorePatternsstring[][]Variable names to skip

Type Comparison

The plugin handles common type equivalences when comparing JSDoc to TypeScript types:

  • Array<T> matches T[]
  • String/Number/Boolean match string/number/boolean
  • ?T (nullable) matches T | null or T | undefined
  • * matches any or unknown
  • Union types with different ordering (e.g., string | number matches number | string)
  • void matches undefined