Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Include all rest arguments in error span
  • Loading branch information
ahejlsberg committed Nov 14, 2020
commit 9c277396915b09ede48b49466998e47e9db85cc3
6 changes: 5 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26926,7 +26926,11 @@ namespace ts {
}
if (restType) {
const spreadType = getSpreadArgumentType(args, argCount, args.length, restType, /*context*/ undefined, checkMode);
const errorNode = reportErrors ? argCount < args.length ? args[argCount] : node : undefined;
const restArgCount = args.length - argCount;
const errorNode = !reportErrors ? undefined :
restArgCount === 0 ? node :
restArgCount === 1 ? args[argCount] :
setTextRangePosEnd(createSyntheticExpression(node, spreadType), args[argCount].pos, args[args.length - 1].end);
if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) {
Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
Expand Down