Skip to content

Commit

Permalink
Fix a bug where default import statements were not renamed correctly …
Browse files Browse the repository at this point in the history
…when resolving a .d.ts rollup naming conflict
  • Loading branch information
octogonz committed Mar 6, 2020
1 parent f82d777 commit 05fc1ee
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion apps/api-extractor/src/generators/DtsEmitHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export class DtsEmitHelpers {
public static emitImport(stringWriter: StringWriter, collectorEntity: CollectorEntity, astImport: AstImport): void {
switch (astImport.importKind) {
case AstImportKind.DefaultImport:
stringWriter.writeLine(`import ${astImport.exportName} from '${astImport.modulePath}';`);
if (collectorEntity.nameForEmit !== astImport.exportName) {
stringWriter.write(`import { default as ${collectorEntity.nameForEmit} }`);
} else {
stringWriter.write(`import ${astImport.exportName}`);
}
stringWriter.writeLine(` from '${astImport.modulePath}';`);
break;
case AstImportKind.NamedImport:
if (collectorEntity.nameForEmit !== astImport.exportName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// <reference types="jest" />
/// <reference lib="es2015.symbol.wellknown" />
/// <reference lib="es2018.intl" />
import Long from 'long';
import { default as Long_2 } from 'long';
import { MAX_UNSIGNED_VALUE } from 'long';

/**
Expand Down Expand Up @@ -309,7 +309,7 @@ declare const unexportedCustomSymbol: unique symbol;

/** @public */
export declare class UseLong {
use_long(): Long;
use_long(): Long_2;
}

/* Excluded from this release type: VARIABLE */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// <reference types="jest" />
/// <reference lib="es2015.symbol.wellknown" />
/// <reference lib="es2018.intl" />
import Long from 'long';
import { default as Long_2 } from 'long';
import { MAX_UNSIGNED_VALUE } from 'long';

/**
Expand Down Expand Up @@ -302,7 +302,7 @@ declare const unexportedCustomSymbol: unique symbol;

/** @public */
export declare class UseLong {
use_long(): Long;
use_long(): Long_2;
}

/* Excluded from this release type: VARIABLE */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// <reference types="jest" />
/// <reference lib="es2015.symbol.wellknown" />
/// <reference lib="es2018.intl" />
import Long from 'long';
import { default as Long_2 } from 'long';
import { MAX_UNSIGNED_VALUE } from 'long';

/**
Expand Down Expand Up @@ -330,7 +330,7 @@ declare const unexportedCustomSymbol: unique symbol;

/** @public */
export declare class UseLong {
use_long(): Long;
use_long(): Long_2;
}

/** @alpha */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```ts

import Long from 'long';
import { default as Long_2 } from 'long';
import { MAX_UNSIGNED_VALUE } from 'long';

// @public
Expand Down Expand Up @@ -190,7 +190,7 @@ export class TypeReferencesInAedoc {
// @public (undocumented)
export class UseLong {
// (undocumented)
use_long(): Long;
use_long(): Long_2;
}

// @alpha (undocumented)
Expand Down

0 comments on commit 05fc1ee

Please sign in to comment.