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
// Number enum
enum ExampleEnumNumber {
This = 0,
That = 1,
}
const rand1 = Math.random();
let theEnum1: ExampleEnumNumber | null = null;
if (rand1 < 0.3) {
theEnum1 = ExampleEnumNumber.This;
}
if (theEnum1) {
}
// String enum
enum ExampleEnumString {
This = '0',
That = '1',
}
const rand2 = Math.random();
let theEnum2: ExampleEnumString | null = null;
if (rand2 < 0.3) {
theEnum2 = ExampleEnumString.This;
}
if (theEnum2) {
}
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
{
rules: {
"@typescript-eslint/strict-boolean-expressions": ["warn", { "allowNullableEnum": true }]
}
}
};
tsconfig
Expected Result
The if (theEnum2) {
line should not report warning.
Actual Result
Warning from strict-boolean-expressions
rule with { allowNullableEnum: true }
option appears.
Additional Info
PR that implemented the feature: #6096
From the code added in the PR it appears that added test doesn't check a case with { "allowNullableEnum": true }
and code with a string enum.