Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@rfermann

Description

@rfermann
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a lookWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.