Skip to content

Commit

Permalink
fix: newExpression arguments not be traverse issue (#597)
Browse files Browse the repository at this point in the history
Co-authored-by: 华志林 <linmu.hzl@raycloud.com>
  • Loading branch information
J10240221 and 华志林 authored Nov 3, 2021
1 parent e86af59 commit d21264e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ export default class Plugin {

NewExpression(path, state) {
const { node } = path;
this.buildExpressionHandler(node, ['callee', 'arguments'], path, state);
this.buildExpressionHandler(node, ['callee'], path, state);

const argumentsProps = node.arguments.map((_, index) => index);
this.buildExpressionHandler(node.arguments, argumentsProps, path, state);
}

SwitchStatement(path, state) {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/as-arguments-identifier/actual.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { Modal } from 'antd';
const _Modal = bind()(Modal);
const _newModal = new AnyClass(Modal);
4 changes: 3 additions & 1 deletion test/fixtures/as-arguments-identifier/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ var _modal = _interopRequireDefault(require("antd/lib/modal"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _Modal = bind()(_modal.default);
var _Modal = bind()(_modal.default);

var _newModal = new AnyClass(_modal.default);

0 comments on commit d21264e

Please sign in to comment.