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 #3244

Closed
DanielKucal opened this issue Sep 21, 2017 · 11 comments · Fixed by #3246
Closed

TypeError: Cannot read property 'end' of undefined #3244

DanielKucal opened this issue Sep 21, 2017 · 11 comments · Fixed by #3246
Milestone

Comments

@DanielKucal
Copy link
Contributor

Bug Report

  • TSLint version: current master branch (commit d16f7be and previous ones)
  • TypeScript version: tested on globally installed 2.2.2 and 2.5.2 if it matters
  • Running TSLint via: (pick one) CLI, i.e. ./node_modules/.bin/tslint "src/**/*.ts" with npm-linked tslint (I ran yarn compile etc.)

TypeScript code being linted

whole project, about ~13k TypeScript lines

with tslint.json configuration:

{
  "extends": [
    "tslint:recommended"
  ],
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {
    /// Angular rules ///
    "banana-in-box": true,
    "class-name": true,
    "component-class-suffix": true,
    "curly": [true],
    // "component-selector": [true, "element", "my", "kebab-case"],
    "directive-class-suffix": [true, "Directive"],
    "eofline": true,
    // "directive-selector": [true, "attribute", "my", "camelCase"],
    "import-destructuring-spacing": true,
    "invoke-injectable": true,
    "pipe-naming": [true, "camelCase"],
    "use-input-property-decorator": true,
    "use-output-property-decorator": true,
    "use-host-property-decorator": true,
    "use-life-cycle-interface": true,
    "use-pipe-transform-interface": true,
    "template-to-ng-template": true,
    "no-access-missing-member": false,
    "no-forward-ref": true,
    "no-input-rename": false,
    "no-invalid-template-strings": true,
    "no-output-rename": false,
    /// Custom ///
    "array-type": [true, "generic"],
    "arrow-parens": false,
    "binary-expression-operand-order": true,
    "encoding": true,
    "forin": true,
    "trailing-comma": [
      true,
      {
        "multiline": {
          "objects": "always",
          "arrays": "always",
          "functions": "ignore",
          "typeLiterals": "ignore"
        }
      }
    ],
    "interface-name": ["never-prefix"],
    // "linebreak-style": [true, "LF"],
    "no-angle-bracket-type-assertion": false,
    "no-attribute-parameter-decorator": true,
    "no-consecutive-blank-lines": [true, 1],
    "no-default-export": true,
    "no-reference": true,
    "no-require-imports": true,
    "no-sparse-arrays": true,
    "no-unsafe-finally": true,
    "no-unused-variable": false, // doesn't work well with Angular's DI
    "max-file-line-count": {
      "options": [888],
      "severity": "warning"
    },
    "object-literal-shorthand": false,
    "prefer-conditional-expression": {
      "options": [true],
      "severity": "warning"
    },
    "prefer-const": false,
    "prefer-object-spread": true,
    "templates-use-public": true,
    "type-literal-delimiter": true,
    "typedef": [
      true,
      "parameter",
      // "call-signature", // TODO activate it later
       "member-variable-declaration",
      "property-declaration"
    ],
    "typeof-compare": true,
    // General
    "no-console": {
      "options": ["log", "time", "timeEnd", "trace", "assert", "clear",
        "count", "debug", "profile", "profileEnd", "select", "table"],
      "severity": "warning"
    },
    "max-classes-per-file": [false, 0],
    "max-line-length": {
       "options": [120],
      "severity": "warning"
    },
    "member-ordering": [true, {
      "order": [
        "public-static-field",
        "protected-static-field",
        "private-static-field",
        "public-instance-field",
        "protected-instance-field",
        "private-instance-field",
        "public-static-method",
        "protected-static-method",
        "public-constructor",
        "protected-constructor",
        "private-constructor",
        "public-instance-method",
        "protected-instance-method",
        "private-instance-method"
      ]
    }],
    "no-string-literal": false,
    "no-use-before-declare": false, // ignores usages in TypeScript, checks just JS output
    "object-literal-sort-keys": false,
    "one-variable-per-declaration": [true, "ignore-for-loop"],
    "ordered-imports": false,
    "quotemark": [
      true,
      "single",
      "avoid-escape"
    ],
    "semicolon": [true, "always"],
    "variable-name": {
      "options": [
        true,
        "allow-leading-underscore",
        "allow-pascal-case",
        "ban-keywords",
        "check-format"
      ],
      "severity": "warning"
    },
    "whitespace": [true, "check-branch", "check-decl", "check-module", "check-separator", "check-type", "check-preblock"]
  }
}

Actual behavior

I get the following errors:

Daniels-MacBook-Pro:zoomsphere2-web danielkucal$ tsc -v
Version 2.5.2
Daniels-MacBook-Pro:zoomsphere2-web danielkucal$ ./node_modules/.bin/tslint "src/**/*.ts"
TypeError: Cannot read property 'text' of undefined
    at ExpressionCallMetadataWalker.validateCallExpression (/Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/noForwardRefRule.js:58:73)
    at ExpressionCallMetadataWalker.visitCallExpression (/Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/noForwardRefRule.js:44:14)
    at ExpressionCallMetadataWalker.SyntaxWalker.visitNode (/Users/danielkucal/Applications/Angular2/tslint/lib/language/walker/syntaxWalker.js:305:22)
    at /Users/danielkucal/Applications/Angular2/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11963:21)
    at ExpressionCallMetadataWalker.SyntaxWalker.walkChildren (/Users/danielkucal/Applications/Angular2/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at ExpressionCallMetadataWalker.SyntaxWalker.visitPropertyAssignment (/Users/danielkucal/Applications/Angular2/tslint/lib/language/walker/syntaxWalker.js:210:14)
    at ExpressionCallMetadataWalker.SyntaxWalker.visitNode (/Users/danielkucal/Applications/Angular2/tslint/lib/language/walker/syntaxWalker.js:464:22)
    at /Users/danielkucal/Applications/Angular2/tslint/lib/language/walker/syntaxWalker.js:535:63
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12095:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12084:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11963:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12159:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12124:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12084:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12066:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11963:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12093:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12124:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12066:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12095:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12047:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12095:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'end' of undefined
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:158:133)
    at visitNodes (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11908:30)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12039:21)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12030:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
    at visitNode (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:11899:24)
    at Object.forEachChild (/Users/danielkucal/Applications/Angular2/tslint/node_modules/typescript/lib/typescript.js:12037:24)
    at cb (/Users/danielkucal/Applications/Angular2/tslint/lib/rules/trailingCommaRule.js:165:23)
TypeError: Cannot read property 'text' of undefined
    at /Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/noAttributeParameterDecoratorRule.js:55:35
    at /Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/util/function.js:26:59
    at Maybe.bind (/Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/util/function.js:21:20)
    at Maybe.fmap (/Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/util/function.js:26:21)
    at /Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/noAttributeParameterDecoratorRule.js:50:14
    at Object.validate (/Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/walkerFactory/walkerFn.js:18:82)
    at /Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/walkerFactory/walkerFn.js:53:27
    at Array.forEach (native)
    at class_1.visitNode (/Users/danielkucal/Applications/Angular2/zoomsphere2-web/node_modules/codelyzer/walkerFactory/walkerFn.js:51:28)
    at /Users/danielkucal/Applications/Angular2/tslint/lib/language/walker/syntaxWalker.js:535:63

Expected behavior

No TypeErrors.

@ajafff
Copy link
Contributor

ajafff commented Sep 21, 2017

Can you reproduce the error without any third party rules?

@DanielKucal
Copy link
Contributor Author

Yes, I get the same errors when using tslint.json e.g. with this content:

{
  "extends": [
    "tslint:recommended"
  ]
}

@ajafff
Copy link
Contributor

ajafff commented Sep 25, 2017

I found it. trailing-comma does not handle arrow functions without parens around the parameter

@sixrandanes
Copy link

sixrandanes commented Sep 26, 2017

For information, i"ve got the same kind of issue in my project with the last version of yarn@1.1.0 (published 4 days ago) whereas everything works fine with the previous version of yarn@1.0.2... (after removing and installing node_modules)

@ajafff
Copy link
Contributor

ajafff commented Sep 26, 2017

@sixrandanes I don't know how yarn could cause these exceptions. Maybe it installs different versions of tslint?

@jppellerin
Copy link

@ajafff I also don't know how yarn makes anything different, but I experienced the same thing. With yarn@1.1.0 I was getting a ton of errors. Reverting to yarn@1.0.2 solved it. Cleaning out node_modules and clearing the cache and reinstalling would lead to the same problem.

Unrelated, but I don't think tslint is the only one affected by this. nodemon would also be having issues running using yarn@1.1.0.

@sixrandanes
Copy link

sixrandanes commented Sep 26, 2017

@ajaff I don't know either what is the thing that causes these exceptions with the last release of yarn. I haven't had time to investigate on it. An issue should be created in yarn's project if anyone haven"t already reported something like that.

@kyasbal
Copy link

kyasbal commented Sep 28, 2017

I have same issue. And I also installed packages with latest yarn.
I could fix this problem with installing tslint with npm after removing node_modules folder.

@ghost
Copy link

ghost commented Oct 9, 2017

I got this error when trying to extend an abstract class, instead of a lint error saying I can't do that.

@sixrandanes
Copy link

should be fixed with yarn@1.2.1

@ajafff
Copy link
Contributor

ajafff commented Oct 15, 2017

The exception thrown in trailing-comma when linting arrow functions without parens is not related to the failures caused by yarn. That's why this issue is still open.

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

Successfully merging a pull request may close this issue.

6 participants