From aa8a2c0bb45a84d59f5837a488669561517d9b13 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:04:34 -0700 Subject: [PATCH] Remove unused variable in ts transform (#59467) --- src/compiler/transformers/ts.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index d2b3e1121f4..9549d5b322f 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -60,7 +60,6 @@ import { getStrictOptionValue, getTextOfNode, hasDecorators, - hasStaticModifier, hasSyntacticModifier, HeritageClause, Identifier, @@ -266,7 +265,6 @@ export function transformTypeScript(context: TransformationContext) { let currentNamespaceContainerName: Identifier; let currentLexicalScope: SourceFile | Block | ModuleBlock | CaseBlock; let currentScopeFirstDeclarationsOfName: Map<__String, Node> | undefined; - let currentClassHasParameterProperties: boolean | undefined; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -323,7 +321,6 @@ export function transformTypeScript(context: TransformationContext) { // Save state const savedCurrentScope = currentLexicalScope; const savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; - const savedCurrentClassHasParameterProperties = currentClassHasParameterProperties; // Handle state changes before visiting a node. onBeforeVisitNode(node); @@ -336,7 +333,6 @@ export function transformTypeScript(context: TransformationContext) { } currentLexicalScope = savedCurrentScope; - currentClassHasParameterProperties = savedCurrentClassHasParameterProperties; return visited; } @@ -1239,10 +1235,8 @@ export function transformTypeScript(context: TransformationContext) { function visitPropertyNameOfClassElement(member: ClassElement): PropertyName { const name = member.name!; // Computed property names need to be transformed into a hoisted variable when they are used more than once. - // The names are used more than once when: - // - the property is non-static and its initializer is moved to the constructor (when there are parameter property assignments). - // - the property has a decorator. - if (isComputedPropertyName(name) && ((!hasStaticModifier(member) && currentClassHasParameterProperties) || hasDecorators(member) && legacyDecorators)) { + // The names are used more than once when the property has a decorator. + if (legacyDecorators && isComputedPropertyName(name) && hasDecorators(member)) { const expression = visitNode(name.expression, visitor, isExpression); Debug.assert(expression); const innerExpression = skipPartiallyEmittedExpressions(expression);