documentationjs / documentationjs/documentation
TypeError when inferring this for anonymous class declarations
- Dominant language
- JavaScript
- Stars
- 5.8k
- Forks
- 481
- PR merge metrics
- No merged PRs in 30d
Description
When using the `build` function from the documentation v5.3.5 API in Node.js v8.9.3, then the following source code causes a fatal exception:
```js
exports.Named = class {
constructor(name, score, foo, options = {}) {
/** @private */
this._score = score;
}
};
```
The error log:
```
[2018-01-01T07:39:01.605] [ERROR] TypeError: Cannot read property 'name' of null
at ThisExpression (/cargo/dep/service/node_modules/documentation/lib/infer/membership.js:67:67)
at NodePath._call (/cargo/dep/service/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/cargo/dep/service/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/cargo/dep/service/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/cargo/dep/service/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (/cargo/dep/service/node_modules/babel-traverse/lib/context.js:108:19)
at TraversalContext.visit (/cargo/dep/service/node_modules/babel-traverse/lib/context.js:192:19)
at Function.traverse.node (/cargo/dep/service/node_modules/babel-traverse/lib/index.js:114:17)
at traverse (/cargo/dep/service/node_modules/babel-traverse/lib/index.js:79:12)
at NodePath.traverse (/cargo/dep/service/node_modules/babel-traverse/lib/path/index.js:144:25)
```
There are probably good reasons for not declaring classes like in the offending source code, but it should not cause documentation to crash, I suppose.
Could it be that the class is not recognised because of the way it is declared, causing trouble when processing the 'this'-expression?
Regards,
Wouter
Contributor guide
Assessment
This issue has not been assessed yet.