require-throws-description
Require @throws tags to include a human-readable description.
Targeted pattern scopeโ
This rule checks TypeDoc comments on function-like declarations and methods that include a @throws (or @throw) tag.
What this rule reportsโ
This rule reports throws tags that contain no prose description (for example only {TypeError}).
Why this rule existsโ
Error type names alone are not enough for consumers. API docs should explain when/why errors occur.
โ Incorrectโ
/**
* Parse value.
* @param input Input value.
* @throws {TypeError}
*/
export function parseValue(input: string): number {
if (input.length === 0) {
throw new TypeError("Input must not be empty.");
}
return Number.parseInt(input, 10);
}
โ Correctโ
/**
* Parse value.
* @param input Input value.
* @throws {TypeError} When input is empty.
*/
export function parseValue(input: string): number {
if (input.length === 0) {
throw new TypeError("Input must not be empty.");
}
return Number.parseInt(input, 10);
}
Behavior and migration notesโ
No autofix is provided because generated throw descriptions would be guesswork.
ESLint flat config exampleโ
import typedocPlugin from "eslint-plugin-typedoc";
export default [
{
plugins: { typedoc: typedocPlugin },
rules: {
"typedoc/require-throws-description": "error",
},
},
];
When not to use itโ
Disable if your team documents error semantics in separate docs and keeps tags minimal.
Package documentationโ
TypeDoc package documentation:
Further readingโ
Rule catalog ID: R021
Adoption resourcesโ
- Pair with
require-throws-tagto enforce both throw-tag presence and quality.