Skip to content

Commit e59820a

Browse files
committed
fix(function): crash when function is assigned with member expression
esdoc#297
1 parent 333efcb commit e59820a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Doc/FunctionDoc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import babelGenerator from 'babel-generator';
12
import AbstractDoc from './AbstractDoc.js';
23
import ParamParser from '../Parser/ParamParser.js';
34
import NamingUtil from '../Util/NamingUtil.js';
@@ -18,8 +19,9 @@ export default class FunctionDoc extends AbstractDoc {
1819

1920
if (this._node.id) {
2021
if (this._node.id.type === 'MemberExpression') {
21-
// todo: can not reproduce this condition.
22-
// this._value.name = ASTUtil.flattenMemberExpression(this._node.id);
22+
// e.g. foo[bar.baz] = function bal(){}
23+
const expression = babelGenerator(this._node.id).code;
24+
this._value.name = `[${expression}]`;
2325
} else {
2426
this._value.name = this._node.id.name;
2527
}

0 commit comments

Comments
 (0)