@@ -5571,9 +5571,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
55715571 emitDecoratorsOfClass ( node ) ;
55725572 }
55735573
5574+ if ( ! ( node . flags & NodeFlags . Export ) ) {
5575+ return ;
5576+ }
55745577 // If this is an exported class, but not on the top level (i.e. on an internal
55755578 // module), export it
5576- if ( ! isES6ExportedDeclaration ( node ) && ( node . flags & NodeFlags . Export ) ) {
5579+ if ( node . flags & NodeFlags . Default ) {
5580+ // if this is a top level default export of decorated class, write the export after the declaration.
5581+ writeLine ( ) ;
5582+ if ( thisNodeIsDecorated && modulekind === ModuleKind . ES6 ) {
5583+ write ( "export default " ) ;
5584+ emitDeclarationName ( node ) ;
5585+ write ( ";" ) ;
5586+ }
5587+ else if ( modulekind === ModuleKind . System ) {
5588+ write ( `${ exportFunctionForFile } ("default", ` ) ;
5589+ emitDeclarationName ( node ) ;
5590+ write ( ");" ) ;
5591+ }
5592+ else if ( modulekind !== ModuleKind . ES6 ) {
5593+ write ( `exports.default = ` ) ;
5594+ emitDeclarationName ( node ) ;
5595+ write ( ";" ) ;
5596+ }
5597+ }
5598+ else if ( node . parent . kind !== SyntaxKind . SourceFile || ( modulekind !== ModuleKind . ES6 && ! ( node . flags & NodeFlags . Default ) ) ) {
55775599 writeLine ( ) ;
55785600 emitStart ( node ) ;
55795601 emitModuleMemberName ( node ) ;
@@ -5582,13 +5604,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
55825604 emitEnd ( node ) ;
55835605 write ( ";" ) ;
55845606 }
5585- else if ( isES6ExportedDeclaration ( node ) && ( node . flags & NodeFlags . Default ) && thisNodeIsDecorated ) {
5586- // if this is a top level default export of decorated class, write the export after the declaration.
5587- writeLine ( ) ;
5588- write ( "export default " ) ;
5589- emitDeclarationName ( node ) ;
5590- write ( ";" ) ;
5591- }
55925607 }
55935608
55945609 function emitClassLikeDeclarationBelowES6 ( node : ClassLikeDeclaration ) {
@@ -6795,7 +6810,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
67956810 }
67966811 }
67976812
6798- function getExternalModuleNameText ( importNode : ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration ) : string {
6813+ function getExternalModuleNameText ( importNode : ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration , emitRelativePathAsModuleName : boolean ) : string {
6814+ if ( emitRelativePathAsModuleName ) {
6815+ const name = getExternalModuleNameFromDeclaration ( host , resolver , importNode ) ;
6816+ if ( name ) {
6817+ return `"${ name } "` ;
6818+ }
6819+ }
67996820 const moduleName = getExternalModuleName ( importNode ) ;
68006821 if ( moduleName . kind === SyntaxKind . StringLiteral ) {
68016822 return tryRenameExternalModule ( < LiteralExpression > moduleName ) || getLiteralText ( < LiteralExpression > moduleName ) ;
@@ -7355,7 +7376,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
73557376 const dependencyGroups : DependencyGroup [ ] = [ ] ;
73567377
73577378 for ( let i = 0 ; i < externalImports . length ; ++ i ) {
7358- let text = getExternalModuleNameText ( externalImports [ i ] ) ;
7379+ const text = getExternalModuleNameText ( externalImports [ i ] , emitRelativePathAsModuleName ) ;
73597380 if ( hasProperty ( groupIndices , text ) ) {
73607381 // deduplicate/group entries in dependency list by the dependency name
73617382 const groupIndex = groupIndices [ text ] ;
@@ -7371,12 +7392,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
73717392 write ( ", " ) ;
73727393 }
73737394
7374- if ( emitRelativePathAsModuleName ) {
7375- const name = getExternalModuleNameFromDeclaration ( host , resolver , externalImports [ i ] ) ;
7376- if ( name ) {
7377- text = `"${ name } "` ;
7378- }
7379- }
73807395 write ( text ) ;
73817396 }
73827397 write ( `], function(${ exportFunctionForFile } ) {` ) ;
@@ -7419,14 +7434,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
74197434
74207435 for ( const importNode of externalImports ) {
74217436 // Find the name of the external module
7422- let externalModuleName = getExternalModuleNameText ( importNode ) ;
7423-
7424- if ( emitRelativePathAsModuleName ) {
7425- const name = getExternalModuleNameFromDeclaration ( host , resolver , importNode ) ;
7426- if ( name ) {
7427- externalModuleName = `"${ name } "` ;
7428- }
7429- }
7437+ const externalModuleName = getExternalModuleNameText ( importNode , emitRelativePathAsModuleName ) ;
74307438
74317439 // Find the name of the module alias, if there is one
74327440 const importAliasName = getLocalNameForExternalImport ( importNode ) ;
0 commit comments