@@ -11,15 +11,15 @@ import { getDefaultResourceIdentifier } from './parse-utilities';
1111
1212/**
1313 * Parses an export node into the declaration.
14- *
14+ *
1515 * @export
1616 * @param {Resource } resource
1717 * @param {(ExportDeclaration | ExportAssignment) } node
1818 */
1919export function parseExport ( resource : Resource , node : ExportDeclaration | ExportAssignment ) : void {
2020 if ( isExportDeclaration ( node ) ) {
2121 const tsExport = node as ExportDeclaration ;
22- if ( ! isStringLiteral ( tsExport . moduleSpecifier ) ) {
22+ if ( ! isStringLiteral ( tsExport . moduleSpecifier ) && ! tsExport . exportClause ) {
2323 return ;
2424 }
2525 if ( tsExport . getText ( ) . indexOf ( '*' ) > - 1 ) {
@@ -30,22 +30,38 @@ export function parseExport(resource: Resource, node: ExportDeclaration | Export
3030 ) ;
3131 } else if ( tsExport . exportClause && isNamedExports ( tsExport . exportClause ) ) {
3232 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+ ) ;
3438
3539 ex . specifiers = tsExport . exportClause . elements . map (
3640 o => o . propertyName && o . name ?
3741 new SymbolSpecifier ( o . propertyName . text , o . name . text ) :
3842 new SymbolSpecifier ( o . name . text ) ,
3943 ) ;
4044
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+
4151 resource . exports . push ( ex ) ;
4252 }
4353 } else {
4454 const literal = node . expression as Identifier ;
4555 if ( node . isExportEquals ) {
4656 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+ }
4760 } else {
4861 const name = ( literal && literal . text ) ? literal . text : getDefaultResourceIdentifier ( resource ) ;
62+ if ( resource . usages . indexOf ( name ) === - 1 ) {
63+ resource . usages . push ( name ) ;
64+ }
4965 resource . declarations . push ( new DefaultDeclaration ( name , resource ) ) ;
5066 }
5167 }
0 commit comments