Skip to content

Commit 5367249

Browse files
committed
Merge branch 'fixUnionTypeCallSignature' of https://github.com/erictsangx/TypeScript into erictsangx-fixUnionTypeCallSignature
2 parents f34cf80 + 557433e commit 5367249

29 files changed

Lines changed: 75 additions & 74 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ internal/
5454
!tests/cases/projects/projectOption/**/node_modules
5555
!tests/cases/projects/NodeModulesSearch/**/*
5656
!tests/baselines/reference/project/nodeModules*/**/*
57+
.idea

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12096,7 +12096,7 @@ namespace ts {
1209612096
error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
1209712097
}
1209812098
else {
12099-
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
12099+
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType));
1210012100
}
1210112101
return resolveErrorCall(node);
1210212102
}
@@ -12258,7 +12258,7 @@ namespace ts {
1225812258
}
1225912259

1226012260
if (!callSignatures.length) {
12261-
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
12261+
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType));
1226212262
return resolveErrorCall(node);
1226312263
}
1226412264

@@ -12306,7 +12306,7 @@ namespace ts {
1230612306
const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
1230712307
if (!callSignatures.length) {
1230812308
let errorInfo: DiagnosticMessageChain;
12309-
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
12309+
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType));
1231012310
errorInfo = chainDiagnosticMessages(errorInfo, headMessage);
1231112311
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo));
1231212312
return resolveErrorCall(node);

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@
10431043
"category": "Error",
10441044
"code": 2348
10451045
},
1046-
"Cannot invoke an expression whose type lacks a call signature.": {
1046+
"Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures.": {
10471047
"category": "Error",
10481048
"code": 2349
10491049
},

tests/baselines/reference/callOnInstance.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tests/cases/compiler/callOnInstance.ts(1,18): error TS2300: Duplicate identifier
22
tests/cases/compiler/callOnInstance.ts(3,15): error TS2300: Duplicate identifier 'D'.
33
tests/cases/compiler/callOnInstance.ts(7,19): error TS2346: Supplied parameters do not match any signature of call target.
44
tests/cases/compiler/callOnInstance.ts(7,19): error TS2350: Only a void function can be called with the 'new' keyword.
5-
tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
5+
tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'C' has no compatible call signatures.
66

77

88
==== tests/cases/compiler/callOnInstance.ts (5 errors) ====
@@ -25,4 +25,4 @@ tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an exp
2525
declare class C { constructor(value: number); }
2626
(new C(1))(); // Error for calling an instance
2727
~~~~~~~~~~~~
28-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
28+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'C' has no compatible call signatures.

tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
tests/cases/compiler/computedPropertiesInDestructuring1.ts(20,8): error TS2349: Cannot invoke an expression whose type lacks a call signature.
1+
tests/cases/compiler/computedPropertiesInDestructuring1.ts(20,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
22
tests/cases/compiler/computedPropertiesInDestructuring1.ts(21,12): error TS2339: Property 'toExponential' does not exist on type 'string'.
3-
tests/cases/compiler/computedPropertiesInDestructuring1.ts(33,4): error TS2349: Cannot invoke an expression whose type lacks a call signature.
3+
tests/cases/compiler/computedPropertiesInDestructuring1.ts(33,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
44
tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: Operator '+' cannot be applied to types '1' and '{}'.
55

66

@@ -26,7 +26,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365:
2626
// report errors on type errors in computed properties used in destructuring
2727
let [{[foo()]: bar6}] = [{bar: "bar"}];
2828
~~~~~
29-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
29+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
3030
let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}];
3131
~~~~~~~~~~~~~
3232
!!! error TS2339: Property 'toExponential' does not exist on type 'string'.
@@ -43,7 +43,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365:
4343

4444
[{[foo()]: bar4}] = [{bar: "bar"}];
4545
~~~~~
46-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
46+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
4747
[{[(1 + {})]: bar4}] = [{bar: "bar"}];
4848
~~~~~~
4949
!!! error TS2365: Operator '+' cannot be applied to types '1' and '{}'.

tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(21,8): error TS2349: Cannot invoke an expression whose type lacks a call signature.
1+
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(21,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
22
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(22,12): error TS2339: Property 'toExponential' does not exist on type 'string'.
3-
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(34,4): error TS2349: Cannot invoke an expression whose type lacks a call signature.
3+
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(34,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
44
tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS2365: Operator '+' cannot be applied to types '1' and '{}'.
55

66

@@ -27,7 +27,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS23
2727
// report errors on type errors in computed properties used in destructuring
2828
let [{[foo()]: bar6}] = [{bar: "bar"}];
2929
~~~~~
30-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
30+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
3131
let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}];
3232
~~~~~~~~~~~~~
3333
!!! error TS2339: Property 'toExponential' does not exist on type 'string'.
@@ -44,7 +44,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS23
4444

4545
[{[foo()]: bar4}] = [{bar: "bar"}];
4646
~~~~~
47-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
47+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
4848
[{[(1 + {})]: bar4}] = [{bar: "bar"}];
4949
~~~~~~
5050
!!! error TS2365: Operator '+' cannot be applied to types '1' and '{}'.

tests/baselines/reference/constructableDecoratorOnClass01.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts(4,1): error TS1238: Unable to resolve signature of class decorator when called as an expression.
2-
Cannot invoke an expression whose type lacks a call signature.
2+
Cannot invoke an expression whose type lacks a call signature. Type 'typeof CtorDtor' has no compatible call signatures.
33

44

55
==== tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts (1 errors) ====
@@ -9,7 +9,7 @@ tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts(4,1)
99
@CtorDtor
1010
~~~~~~~~~
1111
!!! error TS1238: Unable to resolve signature of class decorator when called as an expression.
12-
!!! error TS1238: Cannot invoke an expression whose type lacks a call signature.
12+
!!! error TS1238: Cannot invoke an expression whose type lacks a call signature. Type 'typeof CtorDtor' has no compatible call signatures.
1313
class C {
1414

1515
}

tests/baselines/reference/constructorOverloads4.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tests/cases/compiler/constructorOverloads4.ts(2,18): error TS2300: Duplicate identifier 'Function'.
22
tests/cases/compiler/constructorOverloads4.ts(5,21): error TS2300: Duplicate identifier 'Function'.
33
tests/cases/compiler/constructorOverloads4.ts(6,21): error TS2300: Duplicate identifier 'Function'.
4-
tests/cases/compiler/constructorOverloads4.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
4+
tests/cases/compiler/constructorOverloads4.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Function' has no compatible call signatures.
55
tests/cases/compiler/constructorOverloads4.ts(11,1): error TS2348: Value of type 'typeof Function' is not callable. Did you mean to include 'new'?
66

77

@@ -23,7 +23,7 @@ tests/cases/compiler/constructorOverloads4.ts(11,1): error TS2348: Value of type
2323

2424
(new M.Function("return 5"))();
2525
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
26+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Function' has no compatible call signatures.
2727
M.Function("yo");
2828
~~~~~~~~~~~~~~~~
2929
!!! error TS2348: Value of type 'typeof Function' is not callable. Did you mean to include 'new'?

tests/baselines/reference/functionExpressionShadowedByParams.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/compiler/functionExpressionShadowedByParams.ts(3,4): error TS2349: Cannot invoke an expression whose type lacks a call signature.
1+
tests/cases/compiler/functionExpressionShadowedByParams.ts(3,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures.
22
tests/cases/compiler/functionExpressionShadowedByParams.ts(10,9): error TS2339: Property 'apply' does not exist on type 'number'.
33

44

@@ -7,7 +7,7 @@ tests/cases/compiler/functionExpressionShadowedByParams.ts(10,9): error TS2339:
77
b1.toPrecision(2); // should not error
88
b1(12); // should error
99
~~~~~~
10-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
10+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures.
1111
}
1212

1313

tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
22
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
3-
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,14): error TS2349: Cannot invoke an expression whose type lacks a call signature.
3+
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures.
44
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(26,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
55
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(29,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
6-
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,14): error TS2349: Cannot invoke an expression whose type lacks a call signature.
6+
tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
77

88

99
==== tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts (6 errors) ====
@@ -31,7 +31,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn
3131
r.y = 4;
3232
var r6 = d.y(); // error
3333
~~~~~
34-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
34+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures.
3535

3636
}
3737

@@ -59,5 +59,5 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn
5959
r.y = '';
6060
var r6 = d.y(); // error
6161
~~~~~
62-
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
62+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.
6363
}

0 commit comments

Comments
 (0)