Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Consider the following snippet:
constfoo=['a','b','c'];// type: string[]constbar=foo[5];// type: string, value: undefined// Passes the ruleif(foo[5]){console.log(foo[5]);}// Fails the ruleif(bar){console.log(bar);}
Thanks to@Retsam's work on#1534, the first example passes the linter, however as the author mentions in their PR, it doesn't handle less trivial cases, such as storing the value in a variable (which is very common when you want to use the value being tested in the body of theif
).
I realize that supporting this (and other advanced) cases might be a lift. In the meantime, or alternatively, any thoughts on an option to entirely ignore arrays? In the current state, I don't believe there is a way to make the second example above pass the linter without disabling the rule or getting rid of the variable.
I believe such option was mentioned in#1544, for reference.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin | 2.24.0 |
@typescript-eslint/parser | 2.24.0 |
TypeScript | 3.8.3 |
ESLint | 6.8.0 |
node | 12.14.0 |
npm | 6.13.4 |