Skip to content

Commit e97e75b

Browse files
committed
fix: handle rest_pattern in array destructuring and add aliased import test
Address PR review feedback: - Extract `...rest` identifiers from array_pattern in extractDynamicImportNames - Add `{ readFile: rf }` aliased destructuring case to query-walk parity test Impact: 1 functions changed, 5 affected
1 parent 5a086a5 commit e97e75b

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/extractors/javascript.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,10 @@ function extractDynamicImportNames(callNode) {
10561056
for (let i = 0; i < nameNode.childCount; i++) {
10571057
const child = nameNode.child(i);
10581058
if (child.type === 'identifier') names.push(child.text);
1059+
else if (child.type === 'rest_pattern') {
1060+
const inner = child.child(0) || child.childForFieldName('name');
1061+
if (inner && inner.type === 'identifier') names.push(inner.text);
1062+
}
10591063
}
10601064
return names;
10611065
}

tests/engines/query-walk-parity.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ method.bind(ctx);
186186
file: 'test.js',
187187
code: `
188188
const { readFile } = await import('fs/promises');
189+
const { readFile: rf } = await import('node:fs/promises');
189190
const mod = await import('./utils.js');
190191
import('./side-effect.js');
191192
`,

0 commit comments

Comments
 (0)