File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ import { InternalError } from '@microsoft/node-core-library';
88 * Indicates the import kind for an `AstImport`.
99 */
1010export enum AstImportKind {
11+ /**
12+ * An import statement such as `import X from "y";`.
13+ */
14+ DefaultImport ,
15+
1116 /**
1217 * An import statement such as `import { X } from "y";`.
1318 */
@@ -62,6 +67,9 @@ export class AstImport {
6267 * The name depends on the type of import:
6368 *
6469 * ```ts
70+ * // For AstImportKind.DefaultImport style, exportName would be "X" in this example:
71+ * import X from "y";
72+ *
6573 * // For AstImportKind.NamedImport style, exportName would be "X" in this example:
6674 * import { X } from "y";
6775 *
@@ -110,6 +118,8 @@ export class AstImport {
110118 */
111119 public static getKey ( options : IAstImportOptions ) : string {
112120 switch ( options . importKind ) {
121+ case AstImportKind . DefaultImport :
122+ return `${ options . modulePath } :${ options . exportName } ` ;
113123 case AstImportKind . NamedImport :
114124 return `${ options . modulePath } :${ options . exportName } ` ;
115125 case AstImportKind . StarImport :
Original file line number Diff line number Diff line change @@ -474,11 +474,15 @@ export class ExportAnalyzer {
474474 // StringLiteral: pre=['./A']
475475 // SemicolonToken: pre=[;]
476476
477+ const importClause : ts . ImportClause = declaration as ts . ImportClause ;
478+ const exportName : string = importClause . name ?
479+ importClause . name . getText ( ) . trim ( ) : ts . InternalSymbolName . Default ;
480+
477481 if ( externalModulePath !== undefined ) {
478482 return this . _fetchAstImport ( declarationSymbol , {
479- importKind : AstImportKind . NamedImport ,
483+ importKind : AstImportKind . DefaultImport ,
480484 modulePath : externalModulePath ,
481- exportName : ts . InternalSymbolName . Default
485+ exportName
482486 } ) ;
483487 }
484488
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ import { Collector } from '../collector/Collector';
1515export class DtsEmitHelpers {
1616 public static emitImport ( stringWriter : StringWriter , collectorEntity : CollectorEntity , astImport : AstImport ) : void {
1717 switch ( astImport . importKind ) {
18+ case AstImportKind . DefaultImport :
19+ stringWriter . writeLine ( `import ${ astImport . exportName } from '${ astImport . modulePath } ';` ) ;
20+ break ;
1821 case AstImportKind . NamedImport :
1922 if ( collectorEntity . nameForEmit !== astImport . exportName ) {
2023 stringWriter . write ( `import { ${ astImport . exportName } as ${ collectorEntity . nameForEmit } }` ) ;
Original file line number Diff line number Diff line change 1111
1212/// <reference types="jest" />
1313/// <reference lib="es2018.intl" />
14+ import Long from 'long' ;
15+ import { MAX_UNSIGNED_VALUE } from 'long' ;
1416
1517/**
1618 * Example of an abstract class that is directly exported.
@@ -235,6 +237,7 @@ export declare interface ISimpleInterface {
235237}
236238
237239declare const locallyExportedCustomSymbol : unique symbol ;
240+ export { MAX_UNSIGNED_VALUE }
238241
239242/** @public */
240243export declare namespace NamespaceContainingVariable {
@@ -293,6 +296,11 @@ export declare class TypeReferencesInAedoc {
293296
294297declare const unexportedCustomSymbol : unique symbol ;
295298
299+ /** @public */
300+ export declare class UseLong {
301+ use_long ( ) : Long ;
302+ }
303+
296304/* Excluded from this release type: VARIABLE */
297305
298306/**
Original file line number Diff line number Diff line change 1111
1212/// <reference types="jest" />
1313/// <reference lib="es2018.intl" />
14+ import Long from 'long' ;
15+ import { MAX_UNSIGNED_VALUE } from 'long' ;
1416
1517/**
1618 * Example of an abstract class that is directly exported.
@@ -228,6 +230,7 @@ export declare interface ISimpleInterface {
228230}
229231
230232declare const locallyExportedCustomSymbol : unique symbol ;
233+ export { MAX_UNSIGNED_VALUE }
231234
232235/** @public */
233236export declare namespace NamespaceContainingVariable {
@@ -286,6 +289,11 @@ export declare class TypeReferencesInAedoc {
286289
287290declare const unexportedCustomSymbol : unique symbol ;
288291
292+ /** @public */
293+ export declare class UseLong {
294+ use_long ( ) : Long ;
295+ }
296+
289297/* Excluded from this release type: VARIABLE */
290298
291299/**
Original file line number Diff line number Diff line change 1111
1212/// <reference types="jest" />
1313/// <reference lib="es2018.intl" />
14+ import Long from 'long' ;
15+ import { MAX_UNSIGNED_VALUE } from 'long' ;
1416
1517/**
1618 * Example of an abstract class that is directly exported.
@@ -255,6 +257,7 @@ export declare interface ISimpleInterface {
255257}
256258
257259declare const locallyExportedCustomSymbol : unique symbol ;
260+ export { MAX_UNSIGNED_VALUE }
258261
259262/** @public */
260263export declare namespace NamespaceContainingVariable {
@@ -314,6 +317,11 @@ export declare class TypeReferencesInAedoc {
314317
315318declare const unexportedCustomSymbol : unique symbol ;
316319
320+ /** @public */
321+ export declare class UseLong {
322+ use_long ( ) : Long ;
323+ }
324+
317325/** @alpha */
318326export declare const VARIABLE : string ;
319327
Original file line number Diff line number Diff line change 44
55``` ts
66
7+ import Long from ' long' ;
8+ import { MAX_UNSIGNED_VALUE } from ' long' ;
9+
710// @public
811export abstract class AbstractClass {
912 // (undocumented)
@@ -141,6 +144,8 @@ export interface IMergedInterfaceReferencee {
141144export interface ISimpleInterface {
142145}
143146
147+ export { MAX_UNSIGNED_VALUE }
148+
144149// @public (undocumented)
145150export namespace NamespaceContainingVariable {
146151 let // @internal (undocumented)
@@ -174,6 +179,12 @@ export class TypeReferencesInAedoc {
174179 getValue3(arg1 : TypeReferencesInAedoc ): TypeReferencesInAedoc ;
175180}
176181
182+ // @public (undocumented)
183+ export class UseLong {
184+ // (undocumented)
185+ use_long(): Long ;
186+ }
187+
177188// @alpha (undocumented)
178189export const VARIABLE: string ;
179190
Original file line number Diff line number Diff line change 1717 "@types/node" : " 8.5.8" ,
1818 "fs-extra" : " ~7.0.1" ,
1919 "typescript" : " ~3.1.6"
20+ },
21+ "devDependencies" : {
22+ "@types/long" : " 4.0.0" ,
23+ "long" : " ^4.0.0"
2024 }
2125}
Original file line number Diff line number Diff line change @@ -96,6 +96,16 @@ export {
9696 default as ClassExportedAsDefault
9797} from './DefaultExportEdgeCase' ;
9898
99+ /**
100+ * Test that we can correctly carry default imports into the rollup .d.ts file
101+ */
102+ import Long , { MAX_UNSIGNED_VALUE } from "long" ;
103+ export { MAX_UNSIGNED_VALUE } ;
104+ /** @public */
105+ export declare class UseLong {
106+ use_long ( ) : Long ;
107+ }
108+
99109export { ClassWithSymbols , fullyExportedCustomSymbol } from './EcmaScriptSymbols' ;
100110
101111export { ForgottenExportConsumer1 } from './ForgottenExportConsumer1' ;
Original file line number Diff line number Diff line change 88 "declarationMap" : true ,
99 "experimentalDecorators" : true ,
1010 "strictNullChecks" : true ,
11+ "esModuleInterop" : true ,
1112 "types" : [
1213 " node" ,
1314 " jest"
You can’t perform that action at this time.
0 commit comments