bun/no-redundant-catch-type
Disallow : unknown on the variable of a catch clause
fixable
With strict or useUnknownInCatchVariables in tsconfig.json, a catch clause's variable is already unknown. Writing : unknown adds nothing.
--fix removes the annotation.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"bun/no-redundant-catch-type" = "error" # or "warn"Examples#
example.ts1 problem
try {
await save(draft);
} catch (error: unknownWith strict or useUnknownInCatchVariables, a catch variable is already unknown. Remove the annotation.) {
report(error);
}example.tsNo problems
try {
await save(draft);
} catch (error) {
report(error);
}When not to use it#
The rule doesn't read your tsconfig.json. Without strict or useUnknownInCatchVariables, the variable is any, and : unknown is what makes it safe. Leave the rule off in a project like that.