@@ -2782,8 +2782,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2782
2782
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ false);
2783
2783
}
2784
2784
else if (isParameterPropertyDeclaration(declaration, declaration.parent)) {
2785
- // foo = this.bar is illegal in es2022+ useDefineForClassFields when bar is a parameter property
2786
- return !(getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2022 && useDefineForClassFields
2785
+ // foo = this.bar is illegal in useDefineForClassFields when bar is a parameter property
2786
+ return !(useDefineForClassFields
2787
2787
&& getContainingClass(declaration) === getContainingClass(usage)
2788
2788
&& isUsedInFunctionOrInstanceProperty(usage, declaration));
2789
2789
}
@@ -2814,7 +2814,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2814
2814
return true;
2815
2815
}
2816
2816
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
2817
- if (getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2022 && useDefineForClassFields
2817
+ if (useDefineForClassFields
2818
2818
&& getContainingClass(declaration)
2819
2819
&& (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
2820
2820
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
@@ -2971,7 +2971,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2971
2971
case SyntaxKind.PropertyDeclaration:
2972
2972
// static properties in classes introduce temporary variables
2973
2973
if (hasStaticModifier(node)) {
2974
- return target < ScriptTarget.ESNext || !useDefineForClassFields;
2974
+ return !useDefineForClassFields;
2975
2975
}
2976
2976
return requiresScopeChangeWorker((node as PropertyDeclaration).name);
2977
2977
default:
@@ -3389,10 +3389,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3389
3389
// 1. When result is undefined, after checking for a missing "this."
3390
3390
// 2. When result is defined
3391
3391
function checkAndReportErrorForInvalidInitializer() {
3392
- if (propertyWithInvalidInitializer && !( useDefineForClassFields && getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2022) ) {
3392
+ if (propertyWithInvalidInitializer && !useDefineForClassFields) {
3393
3393
// We have a match, but the reference occurred within a property initializer and the identifier also binds
3394
3394
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
3395
- // with ESNext+ useDefineForClassFields because the scope semantics are different.
3395
+ // with useDefineForClassFields because the scope semantics are different.
3396
3396
error(errorLocation,
3397
3397
errorLocation && propertyWithInvalidInitializer.type && textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
3398
3398
? Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
@@ -31739,7 +31739,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
31739
31739
&& !(isAccessExpression(node) && isAccessExpression(node.expression))
31740
31740
&& !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
31741
31741
&& !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & ModifierFlags.Static)
31742
- && (compilerOptions. useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
31742
+ && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
31743
31743
diagnosticMessage = error(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
31744
31744
}
31745
31745
else if (valueDeclaration.kind === SyntaxKind.ClassDeclaration &&
@@ -38429,7 +38429,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
38429
38429
case "length":
38430
38430
case "caller":
38431
38431
case "arguments":
38432
- if (compilerOptions. useDefineForClassFields) {
38432
+ if (useDefineForClassFields) {
38433
38433
break;
38434
38434
}
38435
38435
// fall through
@@ -38634,7 +38634,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
38634
38634
// or the containing class declares instance member variables with initializers.
38635
38635
38636
38636
const superCallShouldBeRootLevel =
38637
- (getEmitScriptTarget(compilerOptions) !== ScriptTarget.ESNext || !useDefineForClassFields) &&
38637
+ (!useDefineForClassFields) &&
38638
38638
(some((node.parent as ClassDeclaration).members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
38639
38639
some(node.parameters, p => hasSyntacticModifier(p, ModifierFlags.ParameterPropertyModifier)));
38640
38640
@@ -42900,7 +42900,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
42900
42900
!legacyDecorators && languageVersion < ScriptTarget.ESNext &&
42901
42901
classOrConstructorParameterIsDecorated(/*useLegacyDecorators*/ false, node);
42902
42902
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion <= ScriptTarget.ES2022;
42903
- const willTransformInitializers = !useDefineForClassFields || languageVersion < ScriptTarget.ES2022 ;
42903
+ const willTransformInitializers = !useDefineForClassFields;
42904
42904
if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
42905
42905
for (const member of node.members) {
42906
42906
if (willTransformStaticElementsOfDecoratedClass && classElementOrClassElementParameterIsDecorated(/*useLegacyDecorators*/ false, member, node)) {
0 commit comments