@@ -23,10 +23,11 @@ namespace ts {
23
23
IsNamedExternalExport = 1 << 4 ,
24
24
IsDefaultExternalExport = 1 << 5 ,
25
25
IsDerivedClass = 1 << 6 ,
26
+ UseImmediatelyInvokedFunctionExpression = 1 << 7 ,
26
27
27
28
HasAnyDecorators = HasConstructorDecorators | HasMemberDecorators ,
28
29
NeedsName = HasStaticInitializedProperties | HasMemberDecorators ,
29
- UseImmediatelyInvokedFunctionExpression = HasAnyDecorators | HasStaticInitializedProperties ,
30
+ MayNeedImmediatelyInvokedFunctionExpression = HasAnyDecorators | HasStaticInitializedProperties ,
30
31
IsExported = IsExportOfNamespace | IsDefaultExternalExport | IsNamedExternalExport ,
31
32
}
32
33
@@ -595,6 +596,7 @@ namespace ts {
595
596
if ( isExportOfNamespace ( node ) ) facts |= ClassFacts . IsExportOfNamespace ;
596
597
else if ( isDefaultExternalModuleExport ( node ) ) facts |= ClassFacts . IsDefaultExternalExport ;
597
598
else if ( isNamedExternalModuleExport ( node ) ) facts |= ClassFacts . IsNamedExternalExport ;
599
+ if ( languageVersion <= ScriptTarget . ES5 && ( facts & ClassFacts . MayNeedImmediatelyInvokedFunctionExpression ) ) facts |= ClassFacts . UseImmediatelyInvokedFunctionExpression ;
598
600
return facts ;
599
601
}
600
602
@@ -665,12 +667,6 @@ namespace ts {
665
667
const iife = createImmediatelyInvokedArrowFunction ( statements ) ;
666
668
setEmitFlags ( iife , EmitFlags . TypeScriptClassWrapper ) ;
667
669
668
- // Class comment is already added by the ES2015 transform when targeting ES5 or below.
669
- // Only add if targetting ES2015+ to prevent duplicates
670
- if ( languageVersion > ScriptTarget . ES5 ) {
671
- addSyntheticLeadingComment ( iife , SyntaxKind . MultiLineCommentTrivia , "* @class " ) ;
672
- }
673
-
674
670
const varStatement = createVariableStatement (
675
671
/*modifiers*/ undefined ,
676
672
createVariableDeclarationList ( [
@@ -679,7 +675,7 @@ namespace ts {
679
675
/*type*/ undefined ,
680
676
iife
681
677
)
682
- ] , languageVersion > ScriptTarget . ES5 ? NodeFlags . Let : undefined )
678
+ ] )
683
679
) ;
684
680
685
681
setOriginalNode ( varStatement , node ) ;
0 commit comments