Closed
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"extends": ["plugin:@typescript-eslint/recommended"]
}
typeof window === undefined
typeof window === null
Expected Result
error Typeof comparisons should be to string literals valid-typeof
Actual Result
🦗
Additional Info
The @typescript-eslint/recommended
ruleset disables the valid-typeof
ESLint rule on the basis that it's covered by TypeScript's "This condition will always return 'false'" handling.
However, this is incorrect: TypeScript does not detect this incorrect condition in the case of null
and undefined
, and so the valid-typeof
rule should be re-enabled in the recommended
preset.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.23.0 |
@typescript-eslint/parser |
4.23.0 |
TypeScript |
4.2.4 |
ESLint |
7.26.0 |
node |
12.13.1 |