ban-types
Disallow certain types.
✅
Extending "plugin:@typescript-eslint/recommended"
in an ESLint configuration enables this rule.
🔧
Some problems reported by this rule are automatically fixable by the --fix
ESLint command line option.
💡
Some problems reported by this rule are manually fixable by editor suggestions.
Some built-in types have aliases, while some types are considered dangerous or harmful. It's often a good idea to ban certain types to help with consistency and safety.
This rule bans specific types and can suggest alternatives. Note that it does not ban the corresponding runtime objects from being used.
.eslintrc.cjs
module.exports = {
"rules": {
"@typescript-eslint/ban-types": "error"
}
};
Try this rule in the playground ↗
Examples
Examples of code with the default options: