@@ -51,7 +51,7 @@ namespace ts {
5151 let currentNamespace : ModuleDeclaration ;
5252 let currentNamespaceContainerName : Identifier ;
5353 let currentScope : SourceFile | Block | ModuleBlock | CaseBlock ;
54- let currentSourceFileTslib : Identifier ;
54+ let currentSourceFileExternalHelpersModuleName : Identifier ;
5555
5656 /**
5757 * Keeps track of whether expression substitution has been enabled for specific edge cases.
@@ -432,22 +432,22 @@ namespace ts {
432432 startLexicalEnvironment ( ) ;
433433 const statements : Statement [ ] = [ ] ;
434434 const statementOffset = addPrologueDirectives ( statements , node . statements ) ;
435- const tslib = createUniqueName ( "tslib" ) ;
436- const tslibImport = createImportDeclaration (
437- createImportClause ( /*name*/ undefined , createNamespaceImport ( tslib ) ) ,
438- createLiteral ( "tslib" )
435+ const externalHelpersModuleName = createUniqueName ( externalHelpersModuleNameText ) ;
436+ const externalHelpersModuleImport = createImportDeclaration (
437+ createImportClause ( /*name*/ undefined , createNamespaceImport ( externalHelpersModuleName ) ) ,
438+ createLiteral ( externalHelpersModuleNameText )
439439 ) ;
440- tslibImport . parent = node ;
441- tslibImport . flags &= ~ NodeFlags . Synthesized ;
442- statements . push ( tslibImport ) ;
440+ externalHelpersModuleImport . parent = node ;
441+ externalHelpersModuleImport . flags &= ~ NodeFlags . Synthesized ;
442+ statements . push ( externalHelpersModuleImport ) ;
443443
444- currentSourceFileTslib = tslib ;
444+ currentSourceFileExternalHelpersModuleName = externalHelpersModuleName ;
445445 addRange ( statements , visitNodes ( node . statements , visitor , isStatement , statementOffset ) ) ;
446446 addRange ( statements , endLexicalEnvironment ( ) ) ;
447- currentSourceFileTslib = undefined ;
447+ currentSourceFileExternalHelpersModuleName = undefined ;
448448
449449 node = updateSourceFileNode ( node , createNodeArray ( statements , node . statements ) ) ;
450- node . tslib = tslib ;
450+ node . externalHelpersModuleName = externalHelpersModuleName ;
451451 }
452452 else {
453453 node = visitEachChild ( node , visitor , context ) ;
@@ -1382,7 +1382,7 @@ namespace ts {
13821382 : undefined ;
13831383
13841384 const helper = createDecorateHelper (
1385- currentSourceFileTslib ,
1385+ currentSourceFileExternalHelpersModuleName ,
13861386 decoratorExpressions ,
13871387 prefix ,
13881388 memberName ,
@@ -1432,7 +1432,7 @@ namespace ts {
14321432 const expression = createAssignment (
14331433 decoratedClassAlias ,
14341434 createDecorateHelper (
1435- currentSourceFileTslib ,
1435+ currentSourceFileExternalHelpersModuleName ,
14361436 decoratorExpressions ,
14371437 getDeclarationName ( node )
14381438 )
@@ -1456,7 +1456,7 @@ namespace ts {
14561456 const result = createAssignment (
14571457 getDeclarationName ( node ) ,
14581458 createDecorateHelper (
1459- currentSourceFileTslib ,
1459+ currentSourceFileExternalHelpersModuleName ,
14601460 decoratorExpressions ,
14611461 getDeclarationName ( node )
14621462 ) ,
@@ -1489,7 +1489,7 @@ namespace ts {
14891489 expressions = [ ] ;
14901490 for ( const decorator of decorators ) {
14911491 const helper = createParamHelper (
1492- currentSourceFileTslib ,
1492+ currentSourceFileExternalHelpersModuleName ,
14931493 transformDecorator ( decorator ) ,
14941494 parameterOffset ,
14951495 /*location*/ decorator . expression ) ;
@@ -1519,13 +1519,13 @@ namespace ts {
15191519 function addOldTypeMetadata ( node : Declaration , decoratorExpressions : Expression [ ] ) {
15201520 if ( compilerOptions . emitDecoratorMetadata ) {
15211521 if ( shouldAddTypeMetadata ( node ) ) {
1522- decoratorExpressions . push ( createMetadataHelper ( currentSourceFileTslib , "design:type" , serializeTypeOfNode ( node ) ) ) ;
1522+ decoratorExpressions . push ( createMetadataHelper ( currentSourceFileExternalHelpersModuleName , "design:type" , serializeTypeOfNode ( node ) ) ) ;
15231523 }
15241524 if ( shouldAddParamTypesMetadata ( node ) ) {
1525- decoratorExpressions . push ( createMetadataHelper ( currentSourceFileTslib , "design:paramtypes" , serializeParameterTypesOfNode ( node ) ) ) ;
1525+ decoratorExpressions . push ( createMetadataHelper ( currentSourceFileExternalHelpersModuleName , "design:paramtypes" , serializeParameterTypesOfNode ( node ) ) ) ;
15261526 }
15271527 if ( shouldAddReturnTypeMetadata ( node ) ) {
1528- decoratorExpressions . push ( createMetadataHelper ( currentSourceFileTslib , "design:returntype" , serializeReturnTypeOfNode ( node ) ) ) ;
1528+ decoratorExpressions . push ( createMetadataHelper ( currentSourceFileExternalHelpersModuleName , "design:returntype" , serializeReturnTypeOfNode ( node ) ) ) ;
15291529 }
15301530 }
15311531 }
@@ -1543,7 +1543,7 @@ namespace ts {
15431543 ( properties || ( properties = [ ] ) ) . push ( createPropertyAssignment ( "returnType" , createArrowFunction ( /*modifiers*/ undefined , /*typeParameters*/ undefined , [ ] , /*type*/ undefined , /*equalsGreaterThanToken*/ undefined , serializeReturnTypeOfNode ( node ) ) ) ) ;
15441544 }
15451545 if ( properties ) {
1546- decoratorExpressions . push ( createMetadataHelper ( currentSourceFileTslib , "design:typeinfo" , createObjectLiteral ( properties , /*location*/ undefined , /*multiLine*/ true ) ) ) ;
1546+ decoratorExpressions . push ( createMetadataHelper ( currentSourceFileExternalHelpersModuleName , "design:typeinfo" , createObjectLiteral ( properties , /*location*/ undefined , /*multiLine*/ true ) ) ) ;
15471547 }
15481548 }
15491549 }
@@ -2234,7 +2234,7 @@ namespace ts {
22342234 statements . push (
22352235 createReturn (
22362236 createAwaiterHelper (
2237- currentSourceFileTslib ,
2237+ currentSourceFileExternalHelpersModuleName ,
22382238 hasLexicalArguments ,
22392239 promiseConstructor ,
22402240 transformFunctionBodyWorker ( < Block > node . body )
@@ -2261,7 +2261,7 @@ namespace ts {
22612261 }
22622262 else {
22632263 return createAwaiterHelper (
2264- currentSourceFileTslib ,
2264+ currentSourceFileExternalHelpersModuleName ,
22652265 hasLexicalArguments ,
22662266 promiseConstructor ,
22672267 < Block > transformConciseBodyWorker ( node . body , /*forceBlockFunctionBody*/ true )
0 commit comments