Skip to content

Commit 745dad7

Browse files
committed
Fix a bug where default import statements were not renamed correctly when resolving a .d.ts rollup naming conflict
1 parent 61a7be5 commit 745dad7

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

apps/api-extractor/src/generators/DtsEmitHelpers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ export class DtsEmitHelpers {
1616
public static emitImport(stringWriter: StringWriter, collectorEntity: CollectorEntity, astImport: AstImport): void {
1717
switch (astImport.importKind) {
1818
case AstImportKind.DefaultImport:
19-
stringWriter.writeLine(`import ${astImport.exportName} from '${astImport.modulePath}';`);
19+
if (collectorEntity.nameForEmit !== astImport.exportName) {
20+
stringWriter.write(`import { default as ${collectorEntity.nameForEmit} }`);
21+
} else {
22+
stringWriter.write(`import ${astImport.exportName}`);
23+
}
24+
stringWriter.writeLine(` from '${astImport.modulePath}';`);
2025
break;
2126
case AstImportKind.NamedImport:
2227
if (collectorEntity.nameForEmit !== astImport.exportName) {

build-tests/api-extractor-test-01/dist/api-extractor-test-01-beta.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/// <reference types="jest" />
1313
/// <reference lib="es2015.symbol.wellknown" />
1414
/// <reference lib="es2018.intl" />
15-
import Long from 'long';
15+
import { default as Long_2 } from 'long';
1616
import { MAX_UNSIGNED_VALUE } from 'long';
1717

1818
/**
@@ -309,7 +309,7 @@ declare const unexportedCustomSymbol: unique symbol;
309309

310310
/** @public */
311311
export declare class UseLong {
312-
use_long(): Long;
312+
use_long(): Long_2;
313313
}
314314

315315
/* Excluded from this release type: VARIABLE */

build-tests/api-extractor-test-01/dist/api-extractor-test-01-public.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/// <reference types="jest" />
1313
/// <reference lib="es2015.symbol.wellknown" />
1414
/// <reference lib="es2018.intl" />
15-
import Long from 'long';
15+
import { default as Long_2 } from 'long';
1616
import { MAX_UNSIGNED_VALUE } from 'long';
1717

1818
/**
@@ -302,7 +302,7 @@ declare const unexportedCustomSymbol: unique symbol;
302302

303303
/** @public */
304304
export declare class UseLong {
305-
use_long(): Long;
305+
use_long(): Long_2;
306306
}
307307

308308
/* Excluded from this release type: VARIABLE */

build-tests/api-extractor-test-01/dist/api-extractor-test-01.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/// <reference types="jest" />
1313
/// <reference lib="es2015.symbol.wellknown" />
1414
/// <reference lib="es2018.intl" />
15-
import Long from 'long';
15+
import { default as Long_2 } from 'long';
1616
import { MAX_UNSIGNED_VALUE } from 'long';
1717

1818
/**
@@ -330,7 +330,7 @@ declare const unexportedCustomSymbol: unique symbol;
330330

331331
/** @public */
332332
export declare class UseLong {
333-
use_long(): Long;
333+
use_long(): Long_2;
334334
}
335335

336336
/** @alpha */

build-tests/api-extractor-test-01/etc/api-extractor-test-01.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
```ts
66

7-
import Long from 'long';
7+
import { default as Long_2 } from 'long';
88
import { MAX_UNSIGNED_VALUE } from 'long';
99

1010
// @public
@@ -190,7 +190,7 @@ export class TypeReferencesInAedoc {
190190
// @public (undocumented)
191191
export class UseLong {
192192
// (undocumented)
193-
use_long(): Long;
193+
use_long(): Long_2;
194194
}
195195

196196
// @alpha (undocumented)

0 commit comments

Comments
 (0)