@@ -3189,8 +3189,7 @@ namespace ts {
3189
3189
// A ClassDeclaration is ES6 syntax.
3190
3190
transformFlags = subtreeFlags | TransformFlags . AssertES2015 ;
3191
3191
3192
- // A class with a parameter property assignment, property initializer, computed property name, or decorator is
3193
- // TypeScript syntax.
3192
+ // A class with a parameter property assignment or decorator is TypeScript syntax.
3194
3193
// An exported declaration may be TypeScript syntax, but is handled by the visitor
3195
3194
// for a namespace declaration.
3196
3195
if ( ( subtreeFlags & TransformFlags . ContainsTypeScriptClassSyntax )
@@ -3213,8 +3212,7 @@ namespace ts {
3213
3212
// A ClassExpression is ES6 syntax.
3214
3213
let transformFlags = subtreeFlags | TransformFlags . AssertES2015 ;
3215
3214
3216
- // A class with a parameter property assignment, property initializer, or decorator is
3217
- // TypeScript syntax.
3215
+ // A class with a parameter property assignment or decorator is TypeScript syntax.
3218
3216
if ( subtreeFlags & TransformFlags . ContainsTypeScriptClassSyntax
3219
3217
|| node . typeParameters ) {
3220
3218
transformFlags |= TransformFlags . AssertTypeScript ;
@@ -3310,7 +3308,6 @@ namespace ts {
3310
3308
|| hasModifier ( node , ModifierFlags . TypeScriptModifier )
3311
3309
|| node . typeParameters
3312
3310
|| node . type
3313
- || ( node . name && isComputedPropertyName ( node . name ) ) // While computed method names aren't typescript, the TS transform must visit them to emit property declarations correctly
3314
3311
|| ! node . body ) {
3315
3312
transformFlags |= TransformFlags . AssertTypeScript ;
3316
3313
}
@@ -3341,7 +3338,6 @@ namespace ts {
3341
3338
if ( node . decorators
3342
3339
|| hasModifier ( node , ModifierFlags . TypeScriptModifier )
3343
3340
|| node . type
3344
- || ( node . name && isComputedPropertyName ( node . name ) ) // While computed accessor names aren't typescript, the TS transform must visit them to emit property declarations correctly
3345
3341
|| ! node . body ) {
3346
3342
transformFlags |= TransformFlags . AssertTypeScript ;
3347
3343
}
@@ -3356,12 +3352,16 @@ namespace ts {
3356
3352
}
3357
3353
3358
3354
function computePropertyDeclaration ( node : PropertyDeclaration , subtreeFlags : TransformFlags ) {
3359
- // A PropertyDeclaration is TypeScript syntax.
3360
- let transformFlags = subtreeFlags | TransformFlags . AssertTypeScript ;
3355
+ // A PropertyDeclaration is ESnext syntax.
3356
+ let transformFlags = subtreeFlags | TransformFlags . AssertESNext ;
3361
3357
3362
- // If the PropertyDeclaration has an initializer or a computed name, we need to inform its ancestor
3363
- // so that it handle the transformation.
3364
- if ( node . initializer || isComputedPropertyName ( node . name ) ) {
3358
+ // Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
3359
+ if ( some ( node . decorators ) || hasModifier ( node , ModifierFlags . TypeScriptModifier ) || node . type ) {
3360
+ transformFlags |= TransformFlags . AssertTypeScript ;
3361
+ }
3362
+
3363
+ // Hoisted variables related to class properties should live within the TypeScript class wrapper.
3364
+ if ( isComputedPropertyName ( node . name ) || ( hasStaticModifier ( node ) && node . initializer ) ) {
3365
3365
transformFlags |= TransformFlags . ContainsTypeScriptClassSyntax ;
3366
3366
}
3367
3367
@@ -3762,6 +3762,8 @@ namespace ts {
3762
3762
break ;
3763
3763
3764
3764
case SyntaxKind . ComputedPropertyName :
3765
+ // Computed property names are transformed by the ESNext transformer.
3766
+ transformFlags |= TransformFlags . AssertESNext ;
3765
3767
// Even though computed property names are ES6, we don't treat them as such.
3766
3768
// This is so that they can flow through PropertyName transforms unaffected.
3767
3769
// Instead, we mark the container as ES6, so that it can properly handle the transform.
0 commit comments