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

The 'unnecessary-else' rule threw an error: TypeError: Cannot read property 'kind' of undefined #4578

Closed
JoshuaKGoldberg opened this issue Mar 13, 2019 · 4 comments · Fixed by #4603

Comments

@JoshuaKGoldberg
Copy link
Contributor

Bug Report

  • TSLint version: 5.14.0
  • TypeScript version: 3.3.3333
  • Running TSLint via: (pick one) CLI

TypeScript code being linted

https://github.com/Microsoft/tslint-microsoft-contrib/blob/ee64b75d68af267017e6bc861588c36f068de42c/src/functionNameRule.ts

with tslint.json configuration:

{
    "rules": {
        "no-unnecessary-else": true
    }
}

Actual behavior

The 'unnecessary-else' rule threw an error in '/home/travis/build/Microsoft/tslint-microsoft-contrib/src/functionNameRule.ts':
TypeError: Cannot read property 'kind' of undefined
    at getJumpStatement (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/tslint/lib/rules/unnecessaryElseRule.js:70:17)
    at cb (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/tslint/lib/rules/unnecessaryElseRule.js:56:19)
    at visitNodes (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/typescript/lib/typescript.js:15837:30)
    at Object.forEachChild (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/typescript/lib/typescript.js:16063:24)
    at cb (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/tslint/lib/rules/unnecessaryElseRule.js:63:19)
    at visitNode (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/typescript/lib/typescript.js:15828:24)
    at Object.forEachChild (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/typescript/lib/typescript.js:16077:21)
    at cb (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/tslint/lib/rules/unnecessaryElseRule.js:63:19)
    at visitNodes (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/typescript/lib/typescript.js:15837:30)
    at Object.forEachChild (/home/travis/build/Microsoft/tslint-microsoft-contrib/node_modules/typescript/lib/typescript.js:16063:24)

See https://travis-ci.org/Microsoft/tslint-microsoft-contrib/jobs/505584920.

Expected behavior

No errors

@sandersn
Copy link
Contributor

Breaks on several Definitely Typed projects as well: watchify, waitme to name two.

To repro:

  1. Clone DefinitelyTyped/DefinitelyTyped
  2. npm install
  3. npm run lint waitme

@adidahiya
Copy link
Contributor

Are DefinitelyTyped projects often using tslint:all? I wouldn't recommend that; it introduces breaking changes every minor version.

@sandersn
Copy link
Contributor

Yeah, I'm going to change that shortly. I'm not sure why it was that way before I took over the project.

@adidahiya
Copy link
Contributor

@debsmita1 any chance you could take a look at this bug report?

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

Successfully merging a pull request may close this issue.

3 participants