jsdoc/no-unnecessary-type-assertion
eslint-plugin-jsdoc
import jsdoc from "eslint-plugin-jsdoc";
export default [
{
plugins: { jsdoc },
rules: {
"jsdoc/no-unnecessary-type-assertion": "error",
},
},
];Reports redundant @type tags that match or broaden the naturally inferred TypeScript type.
/**
* @type {5}
*/
const a = 5;/**
* @param {boolean} a
*/
function quux (a) {
/**
* @type {true}
*/
const b = a;
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
jsdoc/no-unnecessary-type-assertion
eslint-plugin-jsdoc
import jsdoc from "eslint-plugin-jsdoc";
export default [
{
plugins: { jsdoc },
rules: {
"jsdoc/no-unnecessary-type-assertion": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow type assertions that do not change the type of an expression
Normalizes labeled links in @see tags to a canonical {@link} form.
Reports when certain comment structures are always expected.
Reports the name portion of a JSDoc tag if matching or not matching a given regular expression.