Skip to content

Commit 4b77cec

Browse files
committed
Update main.cts
1 parent 41c5df4 commit 4b77cec

File tree

1 file changed

+6
-3
lines changed
  • packages/cli/src/scripts/codemod/transforms/export-maps

1 file changed

+6
-3
lines changed

packages/cli/src/scripts/codemod/transforms/export-maps/main.cts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default function transform(file: FileInfo, api: API): string | undefined
3939
if (spec.type !== 'ImportSpecifier') return;
4040

4141
const importedName = spec.imported.name as string;
42-
const localName = spec.local ? spec.local.name : importedName;
4342

4443
// target component
4544
let componentName = importedName;
@@ -60,8 +59,12 @@ export default function transform(file: FileInfo, api: API): string | undefined
6059
: `${packageName}/${importedName}`; // regular component
6160

6261
const newImport = j.importDeclaration(
63-
//todo: as string
64-
[j.importSpecifier(j.identifier(importedName), j.identifier(localName as string))],
62+
[
63+
j.importSpecifier(
64+
j.identifier(importedName),
65+
j.identifier(spec.local && typeof spec.local.name === 'string' ? spec.local.name : importedName),
66+
),
67+
],
6568
j.literal(newSource),
6669
);
6770

0 commit comments

Comments
 (0)