src/content/docs/linter/rules/use-consistent-enum-value-type.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="TypeScript and TSX" icon="seti:typescript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: :::note This rule belongs to the types domain. This means that its activation will activate the Biome Scanner to scan the files of your project, and enable the type inference engine. Read more about it in the [documentation page](/linter/domains#types) ::: ## Summary - Rule available since: `v2.3.13` - Diagnostic Category: [`lint/nursery/useConsistentEnumValueType`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - This rule belongs to the following domains: - [`types`](/linter/domains#types) - Sources: - Same as [`@typescript-eslint/no-mixed-enums`](https://typescript-eslint.io/rules/no-mixed-enums){
"linter": {
"rules": {
"nursery": {
"useConsistentEnumValueType": "error"
}
}
}
}
Disallow enums from having both number and string members.
TypeScript enums are allowed to assign numeric or string values to their members. Most enums contain either all numbers or all strings, but in theory you can mix-and-match within the same enum. Mixing enum member types is generally considered confusing and a bad practice.
enum Status {
Unknown,
Closed = 1,
Open = 'open',
}
enum Status {
Unknown = 0,
Closed = 1,
Open = 2,
}
enum Status {
Unknown,
Closed,
Open,
}
enum Status {
Unknown = 'unknown',
Closed = 'closed',
Open = 'open',
}