Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript: TypeError: Cannot read property 'type' of null #956

Closed
lautarodragan opened this issue Jul 19, 2017 · 4 comments

Comments

@lautarodragan
Copy link

commented Jul 19, 2017

I'm getting this error when running standard on a typescript project:

$ standard --parser typescript-eslint-parser --plugin typescript "src/**/*.ts"
standard: Unexpected linter output:

TypeError: Cannot read property 'type' of null
    at Referencer.visitFunction (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/escope/lib/referencer.js:258:26)
    at Referencer.FunctionExpression (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/escope/lib/referencer.js:569:18)
    at Referencer.Visitor.visit (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/esrecurse/esrecurse.js:122:34)
    at Referencer.Visitor.visitChildren (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/esrecurse/esrecurse.js:106:26)
    at Referencer.Visitor.visit (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/esrecurse/esrecurse.js:125:14)
    at Referencer.Visitor.visitChildren (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/esrecurse/esrecurse.js:101:38)
    at Referencer.Visitor.visit (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/esrecurse/esrecurse.js:125:14)
    at Referencer.Visitor.visitChildren (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/esrecurse/esrecurse.js:106:26)
    at Referencer.Visitor.visit (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/esrecurse/esrecurse.js:125:14)
    at Referencer.visitExportDeclaration (/home/lautaro/.nvm/versions/node/v8.1.0/lib/node_modules/standard/node_modules/escope/lib/referencer.js:603:22)

Versions of stuff I'm using:

$ node -v
v8.1.0
$ npm -v
5.0.3
$ tsc -v
Version 2.3.4

Followed the instructions on the README. Installed eslint-plugin-typescript and typescript-eslint-parser globally.

Also tried installing standard as a devDependency.

package.json looks like this:

  ...
  "scripts": {
    ...
    "standard": "standard 'src/**/*.ts'"
  },
  "devDependencies": {
    ...
    "eslint-plugin-typescript": "^0.3.0",
    "standard": "^10.0.2",
    "typescript-eslint-parser": "^4.0.0",
  }
  "standard": {
    "parser": "typescript-eslint-parser",
    "plugins": [
      "typescript"
    ]
  }

Tried running npm run standard to use the standard installed on the project instead of the global one, but came to the same result.

Also tried running against *.tsx files (it's a typescript + reactjs project), got the same result.

If I run it with no arguments, it matches against webpack.config.js and devServer.js only, and seems to be working well in that case (reported a bunch of style errors and offered to auto --fix them).

Am I doing anything wrong?

@rochapablo

This comment has been minimized.

Copy link

commented Oct 5, 2017

standard: Unexpected linter output:

TypeError: Cannot read property 'type' of null
    at EventEmitter.JSXOpeningElement (/.../node_modules/eslint-plugin-react/lib/rules/jsx-indent.js:230:32)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.applySelector (/.../node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/.../node_modules/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (/.../node_modules/eslint/lib/util/node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (/.../node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:602:23)
    at CommentEventGenerator.enterNode (/.../node_modules/eslint/lib/util/comment-event-generator.js:98:23)
    at Traverser.enter (/.../node_modules/eslint/lib/eslint.js:929:36)
    at Traverser.__execute (/.../node_modules/estraverse/estraverse.js:397:31)

Running

$ standard --fix --parser typescript-eslint-parser --plugin typescript *.ts
"standard": "^10.0.3",
"typescript": "^2.5.3",
"typescript-eslint-parser": "^8.0.0"
"standard": {
    "global": [...],
    "ignore": [
      "/android",
      "/ios",
      "/node_modules"
    ],
    "rules": {
      "typescript/type-annotation-spacing": "error"
    },
    "parser": "typescript-eslint-parser",
    "plugins": [
      "typescript"
    ]
  },
@adyshimony

This comment has been minimized.

Copy link

commented Jan 29, 2018

@stale

This comment has been minimized.

Copy link

commented May 10, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label May 10, 2018

@feross

This comment has been minimized.

Copy link
Member

commented May 11, 2018

The workaround for this issue is:

ESLint doesn’t support catch clauses without a parameter, as they’re not yet part of JavaScript. Using catch (_) or similar instead should fix the issue.

Mentioned in this comment: eslint/typescript-eslint-parser#439 (comment)

@feross feross closed this May 11, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.