File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -246,7 +246,10 @@ async (txt, ctx) => {
246
246
*/
247
247
export type SymbolMap = Record <
248
248
string ,
249
- Record < string , { moduleSpecifier : string ; isTypeOnly ?: boolean } >
249
+ Record <
250
+ string ,
251
+ { moduleSpecifier : string ; isTypeOnly ?: boolean ; name ?: string }
252
+ >
250
253
> ;
251
254
252
255
/**
@@ -271,11 +274,12 @@ export const rewriteImport = (
271
274
const name = namedImport . getName ( ) ;
272
275
const alias = namedImport . getAliasNode ( ) ?. getText ( ) ;
273
276
const isTypeOnly = namedImport . isTypeOnly ( ) ;
274
- if ( symbolMapForModule [ name ] ) {
277
+ const rewriter = symbolMapForModule [ name ] ;
278
+ if ( rewriter ) {
275
279
const {
276
280
moduleSpecifier : newModuleSpecifier ,
277
281
isTypeOnly : newIsTypeOnly ,
278
- } = symbolMapForModule [ name ] ;
282
+ } = rewriter ;
279
283
namedImport . remove ( ) ;
280
284
if ( ! newImports [ newModuleSpecifier ] ) {
281
285
newImports [ newModuleSpecifier ] = {
@@ -287,8 +291,8 @@ export const rewriteImport = (
287
291
const namedImports = newImports [ newModuleSpecifier ] . namedImports ;
288
292
if ( Array . isArray ( namedImports ) ) {
289
293
namedImports . push ( {
290
- name,
291
- alias,
294
+ name : rewriter . name ?? name ,
295
+ alias : alias ?? name ,
292
296
isTypeOnly : newIsTypeOnly ?? isTypeOnly ,
293
297
} ) ;
294
298
}
You can’t perform that action at this time.
0 commit comments