From c2434b6ea3f7483a4ca36701e5a20336fb918f71 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 21:19:24 +0000 Subject: [PATCH] Fix line endings after formatting --- src/compiler/checker.ts | 94 ++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c9c07be25a2..ebdebec6c03 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -36062,17 +36062,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const restType = getNonArrayRestType(signature); const argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (let i = 0; i < argCount; i++) { - const arg = args[i]; - if (arg.kind !== SyntaxKind.OmittedExpression) { - const paramType = getTypeAtPosition(signature, i); - const argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); - // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - // Also skip fresh literal checking when the call is in certain destructuring contexts that can cause - // incorrect excess property errors (see #41548). - const shouldSkipFreshness = (checkMode & CheckMode.SkipContextSensitive) || - (isCallExpression(node) && isCallInProblematicDestructuringContext(node)); + const arg = args[i]; + if (arg.kind !== SyntaxKind.OmittedExpression) { + const paramType = getTypeAtPosition(signature, i); + const argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); + // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + // Also skip fresh literal checking when the call is in certain destructuring contexts that can cause + // incorrect excess property errors (see #41548). + const shouldSkipFreshness = (checkMode & CheckMode.SkipContextSensitive) || + (isCallExpression(node) && isCallInProblematicDestructuringContext(node)); const checkArgType = shouldSkipFreshness ? getRegularTypeOfObjectLiteral(argType) : argType; const effectiveCheckArgumentNode = getEffectiveCheckNode(arg); if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? effectiveCheckArgumentNode : undefined, effectiveCheckArgumentNode, headMessage, containingMessageChain, errorOutputContainer)) { @@ -36418,42 +36418,42 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { chain = chainDiagnosticMessages(chain, headMessage); return createDiagnosticForNodeArrayFromMessageChain(getSourceFileOfNode(node), typeArguments, chain); } - return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); - } - - function isCallInProblematicDestructuringContext(node: CallLikeExpression): boolean { - // Check if this call expression is used as the initializer in a variable declaration with a destructuring pattern - const parent = node.parent; - if (parent && isVariableDeclaration(parent) && parent.initializer === node) { - if (isArrayBindingPattern(parent.name)) { - // Check if we're destructuring at a position that causes inference issues - // Based on investigation, positions like 2, 4, 7, etc. can cause problems - const elements = parent.name.elements; - for (let i = 0; i < elements.length; i++) { - const element = elements[i]; - if (!isOmittedExpression(element) && i >= 2) { - // Position 2 and higher can trigger the issue - return true; - } - } - } - } - - // Check for assignment expressions: [a, b, c] = foo() - if (parent && isBinaryExpression(parent) && parent.operatorToken.kind === SyntaxKind.EqualsToken && parent.right === node) { - if (isArrayLiteralExpression(parent.left)) { - // Similar check for assignment destructuring - const elements = parent.left.elements; - for (let i = 0; i < elements.length; i++) { - const element = elements[i]; - if (!isOmittedExpression(element) && i >= 2) { - return true; - } - } - } - } - - return false; + return createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); + } + + function isCallInProblematicDestructuringContext(node: CallLikeExpression): boolean { + // Check if this call expression is used as the initializer in a variable declaration with a destructuring pattern + const parent = node.parent; + if (parent && isVariableDeclaration(parent) && parent.initializer === node) { + if (isArrayBindingPattern(parent.name)) { + // Check if we're destructuring at a position that causes inference issues + // Based on investigation, positions like 2, 4, 7, etc. can cause problems + const elements = parent.name.elements; + for (let i = 0; i < elements.length; i++) { + const element = elements[i]; + if (!isOmittedExpression(element) && i >= 2) { + // Position 2 and higher can trigger the issue + return true; + } + } + } + } + + // Check for assignment expressions: [a, b, c] = foo() + if (parent && isBinaryExpression(parent) && parent.operatorToken.kind === SyntaxKind.EqualsToken && parent.right === node) { + if (isArrayLiteralExpression(parent.left)) { + // Similar check for assignment destructuring + const elements = parent.left.elements; + for (let i = 0; i < elements.length; i++) { + const element = elements[i]; + if (!isOmittedExpression(element) && i >= 2) { + return true; + } + } + } + } + + return false; } function resolveCall(node: CallLikeExpression, signatures: readonly Signature[], candidatesOutArray: Signature[] | undefined, checkMode: CheckMode, callChainFlags: SignatureFlags, headMessage?: DiagnosticMessage): Signature {