@@ -11,15 +11,15 @@ import { getDefaultResourceIdentifier } from './parse-utilities';
11
11
12
12
/**
13
13
* Parses an export node into the declaration.
14
- *
14
+ *
15
15
* @export
16
16
* @param {Resource } resource
17
17
* @param {(ExportDeclaration | ExportAssignment) } node
18
18
*/
19
19
export function parseExport ( resource : Resource , node : ExportDeclaration | ExportAssignment ) : void {
20
20
if ( isExportDeclaration ( node ) ) {
21
21
const tsExport = node as ExportDeclaration ;
22
- if ( ! isStringLiteral ( tsExport . moduleSpecifier ) ) {
22
+ if ( ! isStringLiteral ( tsExport . moduleSpecifier ) && ! tsExport . exportClause ) {
23
23
return ;
24
24
}
25
25
if ( tsExport . getText ( ) . indexOf ( '*' ) > - 1 ) {
@@ -30,22 +30,38 @@ export function parseExport(resource: Resource, node: ExportDeclaration | Export
30
30
) ;
31
31
} else if ( tsExport . exportClause && isNamedExports ( tsExport . exportClause ) ) {
32
32
const lib = tsExport . moduleSpecifier as StringLiteral ;
33
- const ex = new NamedExport ( node . getStart ( ) , node . getEnd ( ) , lib . text ) ;
33
+ const ex = new NamedExport (
34
+ node . getStart ( ) ,
35
+ node . getEnd ( ) ,
36
+ lib ? lib . text : getDefaultResourceIdentifier ( resource ) ,
37
+ ) ;
34
38
35
39
ex . specifiers = tsExport . exportClause . elements . map (
36
40
o => o . propertyName && o . name ?
37
41
new SymbolSpecifier ( o . propertyName . text , o . name . text ) :
38
42
new SymbolSpecifier ( o . name . text ) ,
39
43
) ;
40
44
45
+ for ( const spec of ex . specifiers ) {
46
+ if ( resource . usages . indexOf ( spec . alias || spec . specifier ) === - 1 ) {
47
+ resource . usages . push ( spec . alias || spec . specifier ) ;
48
+ }
49
+ }
50
+
41
51
resource . exports . push ( ex ) ;
42
52
}
43
53
} else {
44
54
const literal = node . expression as Identifier ;
45
55
if ( node . isExportEquals ) {
46
56
resource . exports . push ( new AssignedExport ( node . getStart ( ) , node . getEnd ( ) , literal . text , resource ) ) ;
57
+ if ( resource . usages . indexOf ( literal . text ) === - 1 ) {
58
+ resource . usages . push ( literal . text ) ;
59
+ }
47
60
} else {
48
61
const name = ( literal && literal . text ) ? literal . text : getDefaultResourceIdentifier ( resource ) ;
62
+ if ( resource . usages . indexOf ( name ) === - 1 ) {
63
+ resource . usages . push ( name ) ;
64
+ }
49
65
resource . declarations . push ( new DefaultDeclaration ( name , resource ) ) ;
50
66
}
51
67
}
0 commit comments