Skip to content

no-unused-vars breaks when destructuring an argument after applying a decorator #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rfermann opened this issue Feb 19, 2019 · 1 comment
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look

Comments

@rfermann
Copy link

What code were you trying to parse?

I try to lint the following code:

async something(@Arg() { email }: SomeInput): Promise<boolean> {}

The linting crashes with the stack trace listed under "What actually happened?".

Changing the code to:

async something(@Arg() input: SomeInput): Promise<boolean> {}

makes the rule run fine.

I created a repo for easier reproduction: https://github.com/rfermann/args-decorator-parser-error.

What did you expect to happen?
I expect to not get a TypeError during linting

What actually happened?
I got a TypeError during linting:

eslint index.ts

TypeError: Cannot read property 'type' of undefined
at isForInRef (C:\Users\parser-issue\node_modules\eslint\lib\rules\no-unused-vars.js:434:24)
at variable.references.some.ref (C:\Users\parser-issue\node_modules\eslint\lib\rules\no-unused-vars.js:471:21)
at Array.some ()
at isUsedVariable (C:\Users\parser-issue\node_modules\eslint\lib\rules\no-unused-vars.js:470:40)
at collectUnusedVariables (C:\Users\parser-issue\node_modules\eslint\lib\rules\no-unused-vars.js:582:26)
at collectUnusedVariables (C:\Users\parser-issue\node_modules\eslint\lib\rules\no-unused-vars.js:589:17)
at Program:exit (C:\Users\parser-issue\node_modules\eslint\lib\rules\no-unused-vars.js:634:36)
at listeners.(anonymous function).forEach.listener (C:\Users\parser-issue\node_modules\eslint\lib\util\safe-emitter.js:45:58)
at Array.forEach ()
at Object.emit (C:\Users\parser-issue\node_modules\eslint\lib\util\safe-emitter.js:45:38)
Versions

package version
@typescript-eslint/parser 1.3.0
TypeScript 3.3.1
ESLint 5.14.1
node 10.11.0
npm 6.4.1
@rfermann rfermann added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 19, 2019
@armano2
Copy link
Collaborator

armano2 commented Feb 19, 2019

this issue is fixed in #237 you have to wait for new release (>= 1.4)

@armano2 armano2 closed this as completed Feb 19, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look
Projects
None yet
Development

No branches or pull requests

2 participants