File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
2121import type { AstEntity } from '../analyzer/AstEntity' ;
2222import type { IAstModuleExportInfo } from '../analyzer/AstModule' ;
2323import { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter' ;
24+ import { SyntaxHelpers } from '../analyzer/SyntaxHelpers' ;
2425import { ExtractorMessageId } from '../api/ExtractorMessageId' ;
2526import type { ApiReportVariant } from '../api/IConfigFile' ;
2627import type { SymbolMetadata } from '../collector/SymbolMetadata' ;
@@ -224,7 +225,10 @@ export class ApiReportGenerator {
224225 if ( collectorEntity . nameForEmit === exportedName ) {
225226 exportClauses . push ( collectorEntity . nameForEmit ) ;
226227 } else {
227- exportClauses . push ( `${ collectorEntity . nameForEmit } as ${ exportedName } ` ) ;
228+ const safeExportedName : string = SyntaxHelpers . isSafeUnquotedMemberIdentifier ( exportedName )
229+ ? exportedName
230+ : JSON . stringify ( exportedName ) ;
231+ exportClauses . push ( `${ collectorEntity . nameForEmit } as ${ safeExportedName } ` ) ;
228232 }
229233 }
230234 writer . writeLine ( exportClauses . join ( ',\n' ) ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import type { DeclarationMetadata } from '../collector/DeclarationMetadata';
2121import { AstNamespaceImport } from '../analyzer/AstNamespaceImport' ;
2222import type { IAstModuleExportInfo } from '../analyzer/AstModule' ;
2323import { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter' ;
24+ import { SyntaxHelpers } from '../analyzer/SyntaxHelpers' ;
2425import type { AstEntity } from '../analyzer/AstEntity' ;
2526
2627/**
@@ -216,7 +217,10 @@ export class DtsRollupGenerator {
216217 if ( collectorEntity . nameForEmit === exportedName ) {
217218 exportClauses . push ( collectorEntity . nameForEmit ) ;
218219 } else {
219- exportClauses . push ( `${ collectorEntity . nameForEmit } as ${ exportedName } ` ) ;
220+ const safeExportedName : string = SyntaxHelpers . isSafeUnquotedMemberIdentifier ( exportedName )
221+ ? exportedName
222+ : JSON . stringify ( exportedName ) ;
223+ exportClauses . push ( `${ collectorEntity . nameForEmit } as ${ safeExportedName } ` ) ;
220224 }
221225 }
222226 writer . writeLine ( exportClauses . join ( ',\n' ) ) ;
You can’t perform that action at this time.
0 commit comments