diff --git a/packages/unminify/src/transformations/__tests__/smart-inline.spec.ts b/packages/unminify/src/transformations/__tests__/smart-inline.spec.ts index 2621a51a..d8717a0a 100644 --- a/packages/unminify/src/transformations/__tests__/smart-inline.spec.ts +++ b/packages/unminify/src/transformations/__tests__/smart-inline.spec.ts @@ -95,6 +95,7 @@ inlineTest('property access path renaming', const t = s.target; const p = t.parentElement; const v = p.value; +const x = v[index]; const t2 = s.target.parentElement; `, @@ -102,6 +103,7 @@ const t2 = s.target.parentElement; const s_target = s.target; const s_target_parentElement = s_target.parentElement; const s_target_parentElement_value = s_target_parentElement.value; +const s_target_parentElement_value_index = s_target_parentElement_value[index]; const t2 = s.target.parentElement; `, diff --git a/packages/unminify/src/transformations/smart-inline.ts b/packages/unminify/src/transformations/smart-inline.ts index 3e10d95f..fb2b12d2 100644 --- a/packages/unminify/src/transformations/smart-inline.ts +++ b/packages/unminify/src/transformations/smart-inline.ts @@ -223,7 +223,9 @@ function handleDestructuring(j: JSCodeshift, body: StatementKind[], scope: Scope if (declarations.size === 1) { declarations.forEach((declaration) => { // If there's only one declaration, we can rename it to the combined name. - // for example, `const a = b.c;` -> `const b_c = b.c;` + // for example + // `const a = b.c;` -> `const b_c = b.c;` + // `const a = b[c];` -> `const b_c = b[c];` if ( j.VariableDeclaration.check(declaration) && declaration.declarations.length === 1