Skip to content

Commit 273617c

Browse files
Use node.expression as error node for call diagnostics
1 parent ce23093 commit 273617c

35 files changed

+75
-71
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21354,8 +21354,12 @@ namespace ts {
2135421354
return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
2135521355

2135621356
function getCallErrorNode(node: CallLikeExpression): Node {
21357-
if (isCallExpression(node) && isPropertyAccessExpression(node.expression)) {
21358-
return node.expression.name;
21357+
if (isCallExpression(node)) {
21358+
if (isPropertyAccessExpression(node.expression)) {
21359+
return node.expression.name;
21360+
} else {
21361+
return node.expression;
21362+
}
2135921363
}
2136021364
return node;
2136121365
}

tests/baselines/reference/arityErrorRelatedSpanBindingPattern.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts(7,1): error TS2554:
88
function bar(a, b, [c]): void {}
99

1010
foo("", 0);
11-
~~~~~~~~~~
11+
~~~
1212
!!! error TS2554: Expected 3 arguments, but got 2.
1313
!!! related TS6211 tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts:1:20: An argument matching this binding pattern was not provided.
1414

1515
bar("", 0);
16-
~~~~~~~~~~
16+
~~~
1717
!!! error TS2554: Expected 3 arguments, but got 2.
1818
!!! related TS6211 tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts:3:20: An argument matching this binding pattern was not provided.
1919

tests/baselines/reference/baseCheck.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
3030
}
3131

3232
class D extends C { constructor(public z: number) { super(this.z) } } // too few params
33-
~~~~~~~~~~~~~
33+
~~~~~
3434
!!! error TS2554: Expected 2 arguments, but got 1.
3535
!!! related TS6210 tests/cases/compiler/baseCheck.ts:1:34: An argument for 'y' was not provided.
3636
~~~~

tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(16,1): error T
3333
}
3434
foo(10);
3535
foo(); // not ok - needs number
36-
~~~~~
36+
~~~
3737
!!! error TS2554: Expected 1 arguments, but got 0.
3838
!!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts:1:14: An argument for 'a' was not provided.

tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(16,1): error T
3333
}
3434
foo(10);
3535
foo(); // not ok - needs number
36-
~~~~~
36+
~~~
3737
!!! error TS2554: Expected 1 arguments, but got 0.
3838
!!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts:1:14: An argument for 'a' was not provided.

tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): e
2929
}
3030
foo(10);
3131
foo(); // not ok - needs number
32-
~~~~~
32+
~~~
3333
!!! error TS2554: Expected 1 arguments, but got 0.
3434
!!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts:2:14: An argument for 'a' was not provided.
3535
}
3636
foo(10);
3737
foo(); // not ok - needs number
38-
~~~~~
38+
~~~
3939
!!! error TS2554: Expected 1 arguments, but got 0.
4040
!!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts:2:14: An argument for 'a' was not provided.

tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(17,1): e
2323
}
2424
foo(10);
2525
foo(); // not ok
26-
~~~~~
26+
~~~
2727
!!! error TS2554: Expected 1 arguments, but got 0.
2828
!!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts:2:14: An argument for 'a' was not provided.
2929
}
3030
foo(10);
3131
foo(); // not ok - needs number
32-
~~~~~
32+
~~~
3333
!!! error TS2554: Expected 1 arguments, but got 0.
3434
!!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts:2:14: An argument for 'a' was not provided.

tests/baselines/reference/callOverload.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error
1919
!!! error TS2554: Expected 2 arguments, but got 4.
2020
withRest('a', ...n); // no error
2121
withRest();
22-
~~~~~~~~~~
22+
~~~~~~~~
2323
!!! error TS2555: Expected at least 1 arguments, but got 0.
2424
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided.
2525
withRest(...n);

tests/baselines/reference/callWithMissingVoid.errors.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1):
5656
new MyPromise<void>(resolve => resolve()); // no error
5757
new MyPromise<void | number>(resolve => resolve()); // no error
5858
new MyPromise<any>(resolve => resolve()); // error, `any` arguments cannot be omitted
59-
~~~~~~~~~
59+
~~~~~~~
6060
!!! error TS2554: Expected 1 arguments, but got 0.
6161
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided.
6262
new MyPromise<unknown>(resolve => resolve()); // error, `unknown` arguments cannot be omitted
63-
~~~~~~~~~
63+
~~~~~~~
6464
!!! error TS2554: Expected 1 arguments, but got 0.
6565
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided.
6666
new MyPromise<never>(resolve => resolve()); // error, `never` arguments cannot be omitted
67-
~~~~~~~~~
67+
~~~~~~~
6868
!!! error TS2554: Expected 1 arguments, but got 0.
6969
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided.
7070

@@ -78,7 +78,7 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1):
7878
a(4, "hello"); // ok
7979
a(4, "hello", void 0); // ok
8080
a(4); // not ok
81-
~~~~
81+
~
8282
!!! error TS2554: Expected 3 arguments, but got 1.
8383
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:42:23: An argument for 'y' was not provided.
8484

@@ -88,15 +88,15 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1):
8888

8989
b(4, "hello", void 0, 2); // ok
9090
b(4, "hello"); // not ok
91-
~~~~~~~~~~~~~
91+
~
9292
!!! error TS2554: Expected 4 arguments, but got 2.
9393
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:34: An argument for 'z' was not provided.
9494
b(4, "hello", void 0); // not ok
95-
~~~~~~~~~~~~~~~~~~~~~
95+
~
9696
!!! error TS2554: Expected 4 arguments, but got 3.
9797
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:43: An argument for 'what' was not provided.
9898
b(4); // not ok
99-
~~~~
99+
~
100100
!!! error TS2554: Expected 4 arguments, but got 1.
101101
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:23: An argument for 'y' was not provided.
102102

@@ -117,7 +117,7 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1):
117117
...args: TS): void;
118118

119119
call((x: number, y: number) => x + y) // error
120-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120+
~~~~
121121
!!! error TS2554: Expected 3 arguments, but got 1.
122122
!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:73:5: An argument for 'args' was not provided.
123123
call((x: number, y: number) => x + y, 4, 2) // ok

tests/baselines/reference/classCanExtendConstructorFunction.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ tests/cases/conformance/salsa/second.ts(17,15): error TS2345: Argument of type '
3838
class Sql extends Wagon {
3939
constructor() {
4040
super(); // error: not enough arguments
41-
~~~~~~~
41+
~~~~~
4242
!!! error TS2554: Expected 1 arguments, but got 0.
4343
!!! related TS6210 tests/cases/conformance/salsa/first.js:5:16: An argument for 'numberOxen' was not provided.
4444
this.foonly = 12

0 commit comments

Comments
 (0)