mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 03:09:39 -06:00
Fix line endings after formatting
This commit is contained in:
parent
a8310444c5
commit
c2434b6ea3
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user