Tslint: "TypeError: Cannot read property 'end' of undefined"

Created on 30 Nov 2017  Â·  1Comment  Â·  Source: palantir/tslint

Despite the same error message, I don't think this is a dupe of https://github.com/palantir/tslint/issues/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

Bug

Most helpful comment

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

>All comments

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

Was this page helpful?
0 / 5 - 0 ratings