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

"TypeError: Cannot read property 'end' of undefined" #3537

Closed
dylanpyle opened this issue Nov 30, 2017 · 1 comment · Fixed by #3538
Closed

"TypeError: Cannot read property 'end' of undefined" #3537

dylanpyle opened this issue Nov 30, 2017 · 1 comment · Fixed by #3538

Comments

@dylanpyle
Copy link

Despite the same error message, I don't think this is a dupe of #3244 as that appears to have been fixed in 5.8.0.


Bug Report

  • TSLint version: 5.8.0
  • TypeScript version: 2.6.2
  • Running TSLint via: CLI

TypeScript code being linted

export interface SectionPreviewAction = {
  type: 'section-preview/REPLACE_THUMBNAIL_SUCCESS',
  sectionId: string,
  thumbnailUrl: string
};

(yes, this is known bad/invalid code - existed briefly as part of a small refactor)

with tslint.json configuration:

{
  "extends": ["tslint-config-airbnb", "tslint:recommended", "tslint-react"],
  "rules": {
    "eofline": true,
    "function-name": [true, {
      "function-regex": "^[a-zA-Z][\\w\\d]+$"
    }],
    "quotemark": [true, "single", "jsx-single", "avoid-template", "avoid-escape"],
    "import-name": [false],
    "interface-name": [true, "never-prefix"],
    "jsx-boolean-value": [true, "never"],
    "ordered-imports": [true, { "import-sources-order": "any", "named-imports-order": "case-insensitive" }],
    "trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
    "variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case"],
    "typedef": [
      true,
      "parameter",
      "arrow-parameter",
      "property-declaration",
      "call-signature",
      "arrow-call-signature"
    ],
    "max-line-length": [true, 100],
    "object-shorthand-properties-first": [false],
    "indent": [2, "spaces"]
  }
}

Actual behavior

TypeError: Cannot read property 'end' of undefined
    at OneLineWalker.check (/Users/dylan/dev/cala/studio/node_modules/tslint/lib/rules/oneLineRule.js:141:31)
    at cb (/Users/dylan/dev/cala/studio/node_modules/tslint/lib/rules/oneLineRule.js:92:27)
    at visitNodes (/Users/dylan/dev/cala/studio/node_modules/typescript/lib/typescript.js:12699:30)
    at Object.forEachChild (/Users/dylan/dev/cala/studio/node_modules/typescript/lib/typescript.js:12877:24)
    at OneLineWalker.walk (/Users/dylan/dev/cala/studio/node_modules/tslint/lib/rules/oneLineRule.js:138:19)
    at Rule.AbstractRule.applyWithWalker (/Users/dylan/dev/cala/studio/node_modules/tslint/lib/language/rule/abstractRule.js:31:16)
    at Rule.apply (/Users/dylan/dev/cala/studio/node_modules/tslint/lib/rules/oneLineRule.js:34:21)
    at Linter.applyRule (/Users/dylan/dev/cala/studio/node_modules/tslint/lib/linter.js:177:29)
    at /Users/dylan/dev/cala/studio/node_modules/tslint/lib/linter.js:119:85
    at Object.flatMap (/Users/dylan/dev/cala/studio/node_modules/tslint/lib/utils.js:151:29)

ERROR: src/redux/section-previews/actions.ts[8, 18]: An empty interface is equivalent to `{}`.

Expected behavior

ERROR: src/redux/section-previews/actions.ts[10, 14]: statements are not aligned
ERROR: src/redux/section-previews/actions.ts[11, 17]: statements are not aligned
ERROR: src/redux/section-previews/actions.ts[10, 12]: Missing semicolon
ERROR: src/redux/section-previews/actions.ts[11, 15]: Missing semicolon
ERROR: src/redux/section-previews/actions.ts[11, 23]: Missing semicolon
ERROR: src/redux/section-previews/actions.ts[12, 2]: Unnecessary semicolon

— this is the output from tslint 5.5.0, the previous version we used

@ajafff
Copy link
Contributor

ajafff commented Dec 1, 2017

Fix is up at #3538
Suprisingly TypeScript parses this declaration really bad.

adidahiya pushed a commit that referenced this issue Dec 1, 2017
[bugfix] `one-line` fixed crash on syntax error on class and interface
Fixes: #3537
HyphnKnight pushed a commit to HyphnKnight/tslint that referenced this issue Apr 9, 2018
[bugfix] `one-line` fixed crash on syntax error on class and interface
Fixes: palantir#3537
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.

2 participants