Update Baselines, Applied Lint Fixes, and/or Formatted

This commit is contained in:
TypeScript Bot
2025-08-01 23:21:34 +00:00
parent ce30fd05a9
commit 2663fe71d7

View File

@@ -1,67 +1,67 @@
import {
addEmitHelpers,
addRange,
append,
arrayFrom,
BindingElement,
Block,
Bundle,
CaseOrDefaultClause,
chainBundle,
ClassDeclaration,
Debug,
EmitFlags,
ExportAssignment,
ExportSpecifier,
Expression,
firstOrUndefined,
ForOfStatement,
ForStatement,
GeneratedIdentifierFlags,
getEmitFlags,
hasSyntacticModifier,
Identifier,
IdentifierNameMap,
isArray,
isBindingPattern,
isBlock,
isCaseClause,
isCustomPrologue,
isExpression,
isGeneratedIdentifier,
isIdentifier,
isLocalName,
isNamedEvaluation,
isOmittedExpression,
isPrologueDirective,
isSourceFile,
isStatement,
isVariableDeclarationList,
isVariableStatement,
ModifierFlags,
Node,
NodeFlags,
setCommentRange,
setEmitFlags,
setOriginalNode,
setSourceMapRange,
setTextRange,
skipOuterExpressions,
SourceFile,
Statement,
SwitchStatement,
SyntaxKind,
TransformationContext,
TransformFlags,
transformNamedEvaluation,
VariableDeclaration,
VariableDeclarationList,
VariableStatement,
visitArray,
visitEachChild,
visitNode,
visitNodes,
VisitResult,
import {
addEmitHelpers,
addRange,
append,
arrayFrom,
BindingElement,
Block,
Bundle,
CaseOrDefaultClause,
chainBundle,
ClassDeclaration,
Debug,
EmitFlags,
ExportAssignment,
ExportSpecifier,
Expression,
firstOrUndefined,
ForOfStatement,
ForStatement,
GeneratedIdentifierFlags,
getEmitFlags,
hasSyntacticModifier,
Identifier,
IdentifierNameMap,
isArray,
isBindingPattern,
isBlock,
isCaseClause,
isCustomPrologue,
isExpression,
isGeneratedIdentifier,
isIdentifier,
isLocalName,
isNamedEvaluation,
isOmittedExpression,
isPrologueDirective,
isSourceFile,
isStatement,
isVariableDeclarationList,
isVariableStatement,
ModifierFlags,
Node,
NodeFlags,
setCommentRange,
setEmitFlags,
setOriginalNode,
setSourceMapRange,
setTextRange,
skipOuterExpressions,
SourceFile,
Statement,
SwitchStatement,
SyntaxKind,
TransformationContext,
TransformFlags,
transformNamedEvaluation,
VariableDeclaration,
VariableDeclarationList,
VariableStatement,
visitArray,
visitEachChild,
visitNode,
visitNodes,
VisitResult,
} from "../_namespaces/ts.js";
const enum UsingKind {
@@ -289,67 +289,67 @@ export function transformESNext(context: TransformationContext): (x: SourceFile
);
}
return visitEachChild(node, visitor, context);
}
function visitForOfStatement(node: ForOfStatement) {
if (isUsingVariableDeclarationList(node.initializer)) {
// given:
//
// for (using x of y) { ... }
//
// produces a shallow transformation to:
//
// for (const x_1 of y) {
// using x = x_1;
// { ... }
// }
//
// where the original loop body is wrapped in an additional block scope
// to handle shadowing variables naturally through block scoping.
const forInitializer = node.initializer;
const forDecl = firstOrUndefined(forInitializer.declarations) || factory.createVariableDeclaration(factory.createTempVariable(/*recordTempVariable*/ undefined));
const isAwaitUsing = getUsingKindOfVariableDeclarationList(forInitializer) === UsingKind.Async;
const temp = factory.getGeneratedNameForNode(forDecl.name);
const usingVar = factory.updateVariableDeclaration(forDecl, forDecl.name, /*exclamationToken*/ undefined, /*type*/ undefined, temp);
const usingVarList = factory.createVariableDeclarationList([usingVar], isAwaitUsing ? NodeFlags.AwaitUsing : NodeFlags.Using);
const usingVarStatement = factory.createVariableStatement(/*modifiers*/ undefined, usingVarList);
// Wrap the original loop body in an additional block scope to handle shadowing
// Don't create an extra block if the original statement is empty or contains only empty statements
const isEmptyBlock = isBlock(node.statement) && (
node.statement.statements.length === 0 ||
node.statement.statements.every(stmt => stmt.kind === SyntaxKind.EmptyStatement)
);
const shouldWrapInBlock = !isEmptyBlock;
const statements: Statement[] = [usingVarStatement];
if (shouldWrapInBlock) {
const wrappedStatement = isBlock(node.statement) ?
node.statement :
factory.createBlock([node.statement], /*multiLine*/ true);
statements.push(wrappedStatement);
}
else {
statements.push(...(isBlock(node.statement) ? node.statement.statements : [node.statement]))
}
return visitNode(
factory.updateForOfStatement(
node,
node.awaitModifier,
factory.createVariableDeclarationList([
factory.createVariableDeclaration(temp),
], NodeFlags.Const),
node.expression,
factory.createBlock(statements, /*multiLine*/ true),
),
visitor,
isStatement,
);
}
return visitEachChild(node, visitor, context);
return visitEachChild(node, visitor, context);
}
function visitForOfStatement(node: ForOfStatement) {
if (isUsingVariableDeclarationList(node.initializer)) {
// given:
//
// for (using x of y) { ... }
//
// produces a shallow transformation to:
//
// for (const x_1 of y) {
// using x = x_1;
// { ... }
// }
//
// where the original loop body is wrapped in an additional block scope
// to handle shadowing variables naturally through block scoping.
const forInitializer = node.initializer;
const forDecl = firstOrUndefined(forInitializer.declarations) || factory.createVariableDeclaration(factory.createTempVariable(/*recordTempVariable*/ undefined));
const isAwaitUsing = getUsingKindOfVariableDeclarationList(forInitializer) === UsingKind.Async;
const temp = factory.getGeneratedNameForNode(forDecl.name);
const usingVar = factory.updateVariableDeclaration(forDecl, forDecl.name, /*exclamationToken*/ undefined, /*type*/ undefined, temp);
const usingVarList = factory.createVariableDeclarationList([usingVar], isAwaitUsing ? NodeFlags.AwaitUsing : NodeFlags.Using);
const usingVarStatement = factory.createVariableStatement(/*modifiers*/ undefined, usingVarList);
// Wrap the original loop body in an additional block scope to handle shadowing
// Don't create an extra block if the original statement is empty or contains only empty statements
const isEmptyBlock = isBlock(node.statement) && (
node.statement.statements.length === 0 ||
node.statement.statements.every(stmt => stmt.kind === SyntaxKind.EmptyStatement)
);
const shouldWrapInBlock = !isEmptyBlock;
const statements: Statement[] = [usingVarStatement];
if (shouldWrapInBlock) {
const wrappedStatement = isBlock(node.statement) ?
node.statement :
factory.createBlock([node.statement], /*multiLine*/ true);
statements.push(wrappedStatement);
}
else {
statements.push(...(isBlock(node.statement) ? node.statement.statements : [node.statement]));
}
return visitNode(
factory.updateForOfStatement(
node,
node.awaitModifier,
factory.createVariableDeclarationList([
factory.createVariableDeclaration(temp),
], NodeFlags.Const),
node.expression,
factory.createBlock(statements, /*multiLine*/ true),
),
visitor,
isStatement,
);
}
return visitEachChild(node, visitor, context);
}
function visitCaseOrDefaultClause(node: CaseOrDefaultClause, envBinding: Identifier) {