Report arity errors on call target nodes (#54443)

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
Mateusz Burzyński
2023-11-30 00:06:42 +01:00
committed by GitHub
parent 68b9b07264
commit e9737b893c
54 changed files with 125 additions and 137 deletions

View File

@@ -33922,21 +33922,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
function getDiagnosticSpanForCallNode(node: CallExpression, doNotIncludeArguments?: boolean) {
let start: number;
let length: number;
function getDiagnosticSpanForCallNode(node: CallExpression) {
const sourceFile = getSourceFileOfNode(node);
if (isPropertyAccessExpression(node.expression)) {
const nameSpan = getErrorSpanForNode(sourceFile, node.expression.name);
start = nameSpan.start;
length = doNotIncludeArguments ? nameSpan.length : node.end - start;
}
else {
const expressionSpan = getErrorSpanForNode(sourceFile, node.expression);
start = expressionSpan.start;
length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
}
const { start, length } = getErrorSpanForNode(sourceFile, isPropertyAccessExpression(node.expression) ? node.expression.name : node.expression);
return { start, length, sourceFile };
}
@@ -34915,7 +34903,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
}
if (isCallExpression(errorTarget.parent)) {
const { start, length } = getDiagnosticSpanForCallNode(errorTarget.parent, /*doNotIncludeArguments*/ true);
const { start, length } = getDiagnosticSpanForCallNode(errorTarget.parent);
diagnostic.start = start;
diagnostic.length = length;
}