question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rules/no-use-before-define.js: TypeError: Cannot read property '1' of undefined

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.19.0

  • Node Version: v7.10.0

  • npm Version: 4.5.0

What parser (default, Babel-ESLint, etc.) are you using? Babel-ESLint

Please show your full configuration:

FILE: .eslintrc.json

{
  "parser": "babel-eslint",
  "extends": "standard"
}

What did you do? Please include the actual source code causing the issue.

// @flow
type FieldOptions<T> = {| defaultValue: T |}
type DateFieldOptions = {| ...FieldOptions<Date> |}

What did you expect to happen?

What actually happened? Please include the actual, raw output from ESLint.

[eslintbug]$ node_modules/.bin/eslint fields.js 
Cannot read property '1' of undefined
TypeError: Cannot read property '1' of undefined
    at scope.references.forEach.reference (/tmp/eslintbug/node_modules/eslint/lib/rules/no-use-before-define.js:206:83)
    at Array.forEach (native)
    at findVariablesInScope (/tmp/eslintbug/node_modules/eslint/lib/rules/no-use-before-define.js:194:30)
    at EventEmitter.Program:exit (/tmp/eslintbug/node_modules/eslint/lib/rules/no-use-before-define.js:242:21)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:191:7)
    at NodeEventGenerator.applySelector (/tmp/eslintbug/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/tmp/eslintbug/node_modules/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.leaveNode (/tmp/eslintbug/node_modules/eslint/lib/util/node-event-generator.js:317:14)
    at CodePathAnalyzer.leaveNode (/tmp/eslintbug/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:622:23)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, May 20, 2017

Nice find, @mysticatea, knew it was something like that. Honestly I’d much prefer that babel-eslint fix this if possible, so I’m not 100% sure I actually want to submit this patch.

I’ll open an issue over there later today. Thanks!

0reactions
ilyavolodincommented, May 21, 2017

Closing this issue, as it’s a problem with babel-eslint.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property '1' of undefined (JavaScript)
JS arrays are zero-indexed, so the last element is at index array.length - 1 . – SuperStormer. Mar 6 at 19:58.
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
TypeError: Cannot read property '1' of undefined #315 - GitHub
I downloaded the tuyapi library using npm install codetheweb/tuyapi command and then went to tuapi folder and created tu.js file.
Read more >
Uncaught TypeError: Cannot read property '1' of undefined
This error occurs in Chrome Browser when you read a property or call a method on an undefined object . Uncaught TypeError: Cannot...
Read more >
uncaught typeerror: cannot read property '1' of undefined
Solution 1. Accept Solution Reject Solution. Consider the last two iterations of your inner loop on the first iteration of the outer loop:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found