-
Notifications
You must be signed in to change notification settings - Fork 888
no-unused-variable does not recognize destructuring assignment #1127
Comments
Hi @jnu, the warning comes because of the line:
That |
what? yes, it is used. compare the semantically equivalent:
there is, correctly, no lint error in this case. the linter appears not to be catching that |
Whoops, my bad! I just skimmed your code for |
:) thanks! |
So this is actually a somewhat complicated issue... the tricky thing there is that the To determine if a variable is used, we use an API of TypeScript that finds all the references to an identifier. (This is the same API that atom-ts or vscode uses when you select a variable and choose something like "find references"). This is a confusing scenario, because it can be unclear what should happen. And in fact, there are many TS issues about similar situations: microsoft/TypeScript#6459 There's been a recent PR that loos helpful and suggests that this situation may have been fixed: microsoft/TypeScript#7945 Essentially this is an issue that we just have to hope changes in TS, which will fix things here in TSLint. If there's a definite bug in TS (even given the changes above), I'll file an issue with them. |
great, thanks for looking into it! |
Should be fixed by #2235. |
Bug Report
3.6.0
1.8.9
TypeScript code being linted
with
tslint.json
:Actual behavior
Error: unused variable: 'bar'
Expected behavior
should detect that
bar
is used through destructuring assignmentThe text was updated successfully, but these errors were encountered: