Rules
typed-jsdoc provides two rules that keep your JSDoc accurate and in sync with TypeScript's type inference.
tjd/accurate-jsdoc
FixableJSDoc types must match TypeScript's inference. Auto-fixes mismatches.
Bad
/** @returns {string} */
function getValue() {
return 42;
}Good
/** @returns {number} */
function getValue() {
return 42;
}Options
| Option | Type | Default | Description |
|---|---|---|---|
ignorePatterns | string[] | [] | Function names to skip |
inferenceConfidence | number | 0.5 | Minimum confidence for auto-fix (0-1) |
tjd/no-redundant-jsdoc
FixableRemove 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
| Option | Type | Default | Description |
|---|---|---|---|
keepDescriptions | boolean | true | Preserve JSDoc with descriptions |
ignorePatterns | string[] | [] | Variable names to skip |
Type Comparison
The plugin handles common type equivalences when comparing JSDoc to TypeScript types:
Array<T>matchesT[]String/Number/Booleanmatchstring/number/boolean?T(nullable) matchesT | nullorT | undefined*matchesanyorunknown- Union types with different ordering (e.g.,
string | numbermatchesnumber | string) voidmatchesundefined