Did you forget to use await? for call and construct signatures

This commit is contained in:
Andrew Branch 2019-07-03 09:33:03 -07:00
parent 48fc6b8b17
commit a3a076d79f
No known key found for this signature in database
GPG Key ID: 22CCA4B120C427D2
3 changed files with 30 additions and 19 deletions

View File

@ -22342,6 +22342,8 @@ namespace ts {
function invocationErrorDetails(apparentType: Type, kind: SignatureKind): DiagnosticMessageChain {
let errorInfo: DiagnosticMessageChain | undefined;
const isCall = kind === SignatureKind.Call;
const awaitedType = getAwaitedType(apparentType);
const mightWorkWithAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
if (apparentType.flags & TypeFlags.Union) {
const types = (apparentType as UnionType).types;
let hasSignatures = false;
@ -22408,9 +22410,9 @@ namespace ts {
}
return chainDiagnosticMessages(
errorInfo,
isCall ?
Diagnostics.This_expression_is_not_callable :
Diagnostics.This_expression_is_not_constructable
mightWorkWithAwait
? isCall ? Diagnostics.This_expression_is_not_callable_Did_you_forget_to_use_await : Diagnostics.This_expression_is_not_constructable_Did_you_forget_to_use_await
: isCall ? Diagnostics.This_expression_is_not_callable : Diagnostics.This_expression_is_not_constructable
);
}
function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) {

View File

@ -2705,50 +2705,58 @@
"category": "Error",
"code": 2775
},
"This expression is not callable. Did you forget to use 'await'?": {
"category": "Error",
"code": 2776
},
"This expression is not constructable. Did you forget to use 'await'?": {
"category": "Error",
"code": 2777
},
"The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. Did you forget to use 'await'?": {
"category": "Error",
"code": 2777
},
"Type '{0}' must have a '[Symbol.iterator]()' method that returns an iterator. Did you forget to use 'await'?": {
"category": "Error",
"code": 2777
},
"Type '{0}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. Did you forget to use 'await'?": {
"category": "Error",
"code": 2778
},
"Type '{0}' is not an array type. Did you forget to use 'await'?": {
"Type '{0}' must have a '[Symbol.iterator]()' method that returns an iterator. Did you forget to use 'await'?": {
"category": "Error",
"code": 2779
},
"Type '{0}' is not an array type or a string type. Did you forget to use 'await'?": {
"Type '{0}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. Did you forget to use 'await'?": {
"category": "Error",
"code": 2780
},
"Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator. Did you forget to use 'await'?": {
"Type '{0}' is not an array type. Did you forget to use 'await'?": {
"category": "Error",
"code": 2781
},
"Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator. Did you forget to use 'await'?": {
"Type '{0}' is not an array type or a string type. Did you forget to use 'await'?": {
"category": "Error",
"code": 2782
},
"Argument of type '{0}' is not assignable to parameter of type '{1}'. Did you forget to use 'await'?": {
"Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator. Did you forget to use 'await'?": {
"category": "Error",
"code": 2783
},
"Type '{0}' has no call signatures. Did you forget to use 'await'?": {
"Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator. Did you forget to use 'await'?": {
"category": "Error",
"code": 2784
},
"Type '{0}' has no construct signatures. Did you forget to use 'await'?": {
"Argument of type '{0}' is not assignable to parameter of type '{1}'. Did you forget to use 'await'?": {
"category": "Error",
"code": 2785
},
"This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap. Did you forget to use 'await'?": {
"Type '{0}' has no call signatures. Did you forget to use 'await'?": {
"category": "Error",
"code": 2786
},
"Type '{0}' has no construct signatures. Did you forget to use 'await'?": {
"category": "Error",
"code": 2787
},
"This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap. Did you forget to use 'await'?": {
"category": "Error",
"code": 2788
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",

View File

@ -24,4 +24,5 @@ async function fn(
e();
f();
new g();
b();
}