File tree 2 files changed +13
-11
lines changed
src/compiler/transformers
tests/baselines/reference 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,10 @@ 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
30
IsExported = IsExportOfNamespace | IsDefaultExternalExport | IsNamedExternalExport ,
31
31
}
32
32
@@ -595,6 +595,11 @@ namespace ts {
595
595
if ( isExportOfNamespace ( node ) ) facts |= ClassFacts . IsExportOfNamespace ;
596
596
else if ( isDefaultExternalModuleExport ( node ) ) facts |= ClassFacts . IsDefaultExternalExport ;
597
597
else if ( isNamedExternalModuleExport ( node ) ) facts |= ClassFacts . IsNamedExternalExport ;
598
+ if ( facts & ClassFacts . HasAnyDecorators ) facts |= ClassFacts . UseImmediatelyInvokedFunctionExpression ;
599
+ if ( facts & ClassFacts . HasStaticInitializedProperties ) {
600
+ if ( languageVersion < ScriptTarget . ESNext ) facts |= ClassFacts . UseImmediatelyInvokedFunctionExpression ;
601
+ else if ( languageVersion === ScriptTarget . ESNext && ! compilerOptions . useDefineForClassFields ) facts |= ClassFacts . UseImmediatelyInvokedFunctionExpression ;
602
+ }
598
603
return facts ;
599
604
}
600
605
Original file line number Diff line number Diff line change @@ -11,13 +11,10 @@ class Foo {
11
11
12
12
//// [thisInClassBodyStaticESNext.js]
13
13
// all are allowed with es-compliant class field emit
14
- let Foo = /** @class */ ( ( ) => {
15
- class Foo {
16
- x = this ;
17
- static t = this ;
18
- static at = ( ) => this ;
19
- static ft = function ( ) { return this ; } ;
20
- static mt ( ) { return this ; }
21
- }
22
- return Foo ;
23
- } ) ( ) ;
14
+ class Foo {
15
+ x = this ;
16
+ static t = this ;
17
+ static at = ( ) => this ;
18
+ static ft = function ( ) { return this ; } ;
19
+ static mt ( ) { return this ; }
20
+ }
You can’t perform that action at this time.
0 commit comments