Skip to content

Commit 044cfbd

Browse files
committed
support inline type
1 parent be4ac92 commit 044cfbd

File tree

1 file changed

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

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ export default function transform(file: FileInfo, api: API): string | undefined
141141
packageNames.forEach((pkg) => {
142142
root.find(j.ImportDeclaration, { source: { value: pkg } }).forEach((importPath) => {
143143
const specifiers = importPath.node.specifiers || [];
144-
specifiers.forEach((spec) => {
144+
specifiers.forEach((spec: any) => {
145145
if (spec.type !== 'ImportSpecifier') return;
146146
const importedName = spec.imported.name as string;
147147
let componentName = importedName;
148148
if (importedName.endsWith('PropTypes')) {
149149
componentName = importedName.replace(/PropTypes$/, '');
150150
} else if (importedName.endsWith('Props')) {
151-
componentName = importedName.replace(/Props$/, '');
151+
componentName = componentName.replace(/Props$/, '');
152152
} else if (importedName.endsWith('DomRef')) {
153-
componentName = importedName.replace(/DomRef$/, '');
153+
componentName = componentName.replace(/DomRef$/, '');
154154
}
155155

156156
let newSource: string;
@@ -178,7 +178,9 @@ export default function transform(file: FileInfo, api: API): string | undefined
178178
],
179179
j.literal(newSource),
180180
);
181-
newImport.importKind = importPath.node.importKind;
181+
if ('importKind' in spec && spec.importKind === 'type') {
182+
newImport.importKind = 'type';
183+
}
182184
j(importPath).insertBefore(newImport);
183185
isDirty = true;
184186
});

0 commit comments

Comments
 (0)