Strange undefined behavior - TypeError: Cannot read property 'prototype' of undefined
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 278
- PR merge metrics
- No merged PRs in 30d
Description
I get this strange error, when I try to import a JS file, which was written in ES6 and transipled to ES5. I was trying to debug, why exactly `inquirer.prompt.prompts[promptType]` gives me `null` and I found out that for some reason after `UI._loop` goes through all `var prompts = ['input', 'checkbox', 'confirm', 'expand', 'list', 'password', 'rawlist'];` it then receives `key = 'min'` ? and consequently `var promptType = prompts[key];` is a `[Function: val]` that returns `Infinity` or `NaN`. Very strange, especially that I am rather new to JS.
```
/Users/asiron/code/ethereum/fincontracts-client/node_modules/vorpal/dist/ui.js:122
inquirer.prompt.prompts[promptType].prototype.getType = function () {
^
TypeError: Cannot read property 'prototype' of undefined
at _loop (/Users/asiron/code/ethereum/fincontracts-client/node_modules/vorpal/dist/ui.js:122:42)
at new UI (/Users/asiron/code/ethereum/fincontracts-client/node_modules/vorpal/dist/ui.js:149:7)
at Object. (/Users/asiron/code/ethereum/fincontracts-client/node_modules/vorpal/dist/ui.js:594:10)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
```
I am using:
```
node: v7.5.0
npm: 4.1.2
babel-cli: ^6.0.0
babel-preset-env: ^1.1.8
vorpal: ^1.11.4
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with the listed Node, npm, Babel, and Vorpal versions, then inspect node_modules/vorpal/dist/ui.js around line 122 and the UI._loop entry point. Trace why the prompt lookup produces an undefined value instead of one of the listed prompt types; done means the import no longer raises this TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100