Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
// from https://www.typescriptlang.org/docs/handbook/enums.html
enum FileAccess {
None,
Read = 1 << 1,
Write = 1 << 2,
ReadWrite = Read | Write,
}
ESLint Config
{
"rules": {
"@typescript-eslint/prefer-literal-enum-member": [
"error", { "allowBitwiseExpressions": true }
]
}
}
tsconfig
Expected Result
There should be no reported error. This is a fairly normal use-case for enums and bitwise operators. The official ts docs even have it as an example.
I would like a way to only allow literal enums, but also allow bitwise in this use case. I can get the code to pass by changing it to, but I feel it makes things less clear:
enum FileAccess {
None,
Read = 1 << 1, // 0b0010
Write = 1 << 2, // 0b0100
ReadWrite = 0b0010 | 0b0100,
}
Actual Result
Recieve error:
@typescript-eslint/prefer-literal-enum-member:
Explicit enum value must only be a literal value (string, number, boolean, etc). 6:3 - 6:12
Additional Info
In the actual code I an writing, I am extending "plugin:@typescript-eslint/strict-type-checked"