Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-unused-variable fails with argument destructuring #1641

Closed
kourge opened this issue Oct 18, 2016 · 4 comments
Closed

no-unused-variable fails with argument destructuring #1641

kourge opened this issue Oct 18, 2016 · 4 comments

Comments

@kourge
Copy link

kourge commented Oct 18, 2016

Bug Report

  • TSLint version: 3.13.0
  • TypeScript version: 2.0.2
  • Running TSLint via: CLI

TypeScript code being linted

interface F {
  range: {
    start: number;
    end: number;
  };
}

function f({range: {start, end}}: F): number {
  return end - start;
}

with tslint.json configuration:

{
  "rules": {
    "no-unused-variable": true
  }
}

Actual behavior

/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:49881
            var flags = symbol.flags;
                              ^

TypeError: Cannot read property 'flags' of undefined
    at displayPartKind (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:49881:31)
    at symbolPart (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:49879:34)
    at Object.writeSymbol (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:49866:31)
    at buildBindingElementDisplay (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:18771:28)
    at /Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:18752:110
    at buildDisplayForCommaSeparatedList (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:18798:21)
    at buildBindingPatternDisplay (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:18752:21)
    at buildParameterDisplay (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:18736:21)
    at buildDisplayForParametersAndDelimiters (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:18826:21)
    at Object.buildSignatureDisplay (/Users/kourge/projects/urbandoor/web-app/node_modules/typescript/lib/typescript.js:18872:17)

Expected behavior

No error.

Additional notes

This error does not happen if any of the following is true:

  • The function is exported
  • The second-level destructuring is removed
@kourge kourge changed the title no-unused-variable and destructuring no-unused-variable fails with argument destructuring Oct 18, 2016
@adidahiya
Copy link
Contributor

the rule doesn't do very well on nested destructuring. related: #1606

we're deprecating the rule in v4.0 anyway, see #1481. I suggest you move to using those compiler options.

@ghost
Copy link

ghost commented Mar 15, 2017

Should be fixed by #2235.

@nchen63 nchen63 closed this as completed Mar 16, 2017
@corydeppen
Copy link
Contributor

I'm seeing the Cannot read property 'flags' of undefined error when the no-unused-variable rule is used with tslint 5.4.3 and tsc 2.4.1. If I remove that rule I no longer see the error.

@victornoel
Copy link

@corydeppen you should open another issue, there is many reason for this error to be printed.
Also see #3001

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants