mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 22:55:36 -05:00
Add specific weak type error for callable types
"Did you mean to call it?"
This commit is contained in:
@@ -8944,7 +8944,15 @@ namespace ts {
|
||||
isWeakType(target) &&
|
||||
!hasCommonProperties(source, target)) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
|
||||
const calls = getSignaturesOfType(source, SignatureKind.Call);
|
||||
const constructs = getSignaturesOfType(source, SignatureKind.Construct);
|
||||
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) ||
|
||||
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) {
|
||||
reportError(Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target));
|
||||
}
|
||||
else {
|
||||
reportError(Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
|
||||
}
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
|
||||
@@ -1908,6 +1908,10 @@
|
||||
"category": "Error",
|
||||
"code": 2559
|
||||
},
|
||||
"Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?": {
|
||||
"category": "Error",
|
||||
"code": 2560
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
|
||||
Reference in New Issue
Block a user