From d21264e4fb9c9f60041ceed748177db16f347ad7 Mon Sep 17 00:00:00 2001 From: zhiLinGeGe Date: Wed, 3 Nov 2021 10:45:56 +0800 Subject: [PATCH] fix: newExpression arguments not be traverse issue (#597) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 华志林 --- src/Plugin.js | 5 ++++- test/fixtures/as-arguments-identifier/actual.js | 1 + test/fixtures/as-arguments-identifier/expected.js | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Plugin.js b/src/Plugin.js index 61cb7d81..a49247fa 100644 --- a/src/Plugin.js +++ b/src/Plugin.js @@ -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) { diff --git a/test/fixtures/as-arguments-identifier/actual.js b/test/fixtures/as-arguments-identifier/actual.js index 65317a5c..6217cf62 100644 --- a/test/fixtures/as-arguments-identifier/actual.js +++ b/test/fixtures/as-arguments-identifier/actual.js @@ -1,2 +1,3 @@ import { Modal } from 'antd'; const _Modal = bind()(Modal); +const _newModal = new AnyClass(Modal); \ No newline at end of file diff --git a/test/fixtures/as-arguments-identifier/expected.js b/test/fixtures/as-arguments-identifier/expected.js index 9b4579e3..8599660a 100644 --- a/test/fixtures/as-arguments-identifier/expected.js +++ b/test/fixtures/as-arguments-identifier/expected.js @@ -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); \ No newline at end of file +var _Modal = bind()(_modal.default); + +var _newModal = new AnyClass(_modal.default); \ No newline at end of file