File tree 2 files changed +25
-0
lines changed
unminify/src/transformations/__tests__
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ export function findReferences(
171
171
) : Collection < Identifier > {
172
172
const targetScope = 'bindings' in nodeOrScope ? nodeOrScope : j ( nodeOrScope ) . get ( ) . scope as Scope
173
173
const range = 'bindings' in nodeOrScope ? nodeOrScope . path : nodeOrScope
174
+ const rangeNode = 'node' in range ? range . node : range
174
175
175
176
return j ( range )
176
177
. find ( j . Identifier , { name : identifierName } )
@@ -179,6 +180,11 @@ export function findReferences(
179
180
// ignore properties (e.g. in MemberExpression
180
181
if ( path . name === 'property' && j . MemberExpression . check ( path . parent . node ) && ! path . parent . node . computed ) return false
181
182
183
+ // ignore function name that is at the top level
184
+ if ( path . parent . node === rangeNode && j . FunctionDeclaration . check ( path . parent . node ) && path . parent . node . id === path . node ) {
185
+ return false
186
+ }
187
+
182
188
if ( ! path . scope ) return false
183
189
184
190
let scope : Scope | null = path . scope
Original file line number Diff line number Diff line change @@ -323,6 +323,25 @@ function foo() {
323
323
` ,
324
324
)
325
325
326
+ inlineTest ( 'property destructuring - resolve naming conflicts #4' ,
327
+ `
328
+ function J(U) {
329
+ const B = U.children;
330
+ const G = U.className;
331
+ const J = U.description;
332
+ }
333
+ ` ,
334
+ `
335
+ function J(U) {
336
+ const {
337
+ children,
338
+ className,
339
+ description
340
+ } = U;
341
+ }
342
+ ` ,
343
+ )
344
+
326
345
inlineTest ( 'array destructuring' ,
327
346
`
328
347
const t = e[0];
You can’t perform that action at this time.
0 commit comments