This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no-unused-variable: don't crash at destructuring (#3058)
Avoid typescript crash when trying to get type of destructured variable declaration. Also avoid walking the AST multiple times when `--declaration` is not enabled. That should result in better performance and fewer false negatives. [bugfix] `no-unused-variable` fixed crash when using destructuring Fixes: #2876 Fixes: #3001
- Loading branch information
Showing
3 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
test/rules/no-unused-variable/type-checked/destructuring.ts.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { SomeClass, someVar } from "./some.test"; | ||
const person = { name: "alice" }; | ||
const { name } = person; | ||
~~~~ ['name' is declared but never used.] | ||
|
||
export const {prop} = someVar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class SomeClass {} | ||
|
||
export const someVar = {prop: new SomeClass()}; |