Skip to content

Ban Types

Error
small-rules/ban-types

Ban configured TypeScript utility types, defaulting to Omit in favor of Except.

Diagnostic Messages

bannedType
Type '{{typeName}}' is banned by project configuration. Use the project-preferred alternative for this type.
bannedTypeWithReplacement
Type '{{typeName}}' is banned. Use '{{replacementName}}' instead.

Configuration

This rule accepts one options object after the severity.

bannedTypesOptional

Array of banned type names or an object mapping banned type names to preferred replacement names.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/ban-types": [
"error",
{
"bannedTypes": {
"Omit": "Except"
}
}
]
}
}

Examples

Disallowed Omit utility type
type User = {
readonly name: string;
readonly password: string;
};
type HiddenUser = Omit<User, "password">;
Allowed Pick utility type
type User = {
readonly name: string;
};
type ActiveUser = Pick<User, "name">;