mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Refactor to use related info everywhere
This commit is contained in:
@@ -933,15 +933,16 @@ namespace ts {
|
||||
}
|
||||
|
||||
function errorAndMaybeSuggestAwait(
|
||||
location: Node | undefined,
|
||||
location: Node,
|
||||
maybeMissingAwait: boolean,
|
||||
defaultMessage: DiagnosticMessage,
|
||||
missingAwaitMessage: DiagnosticMessage,
|
||||
message: DiagnosticMessage,
|
||||
arg0?: string | number | undefined, arg1?: string | number | undefined, arg2?: string | number | undefined, arg3?: string | number | undefined): Diagnostic {
|
||||
const diagnostic = error(location, message, arg0, arg1, arg2, arg3);
|
||||
if (maybeMissingAwait) {
|
||||
return error(location, missingAwaitMessage, arg0, arg1, arg2, arg3);
|
||||
const related = createDiagnosticForNode(location, Diagnostics.Did_you_forget_to_use_await);
|
||||
addRelatedInfo(diagnostic, related);
|
||||
}
|
||||
return error(location, defaultMessage, arg0, arg1, arg2, arg3);
|
||||
return diagnostic;
|
||||
}
|
||||
|
||||
function createSymbol(flags: SymbolFlags, name: __String, checkFlags?: CheckFlags) {
|
||||
@@ -22350,11 +22351,11 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function invocationErrorDetails(apparentType: Type, kind: SignatureKind): DiagnosticMessageChain {
|
||||
function invocationErrorDetails(apparentType: Type, kind: SignatureKind): { messageChain: DiagnosticMessageChain, relatedMessage: DiagnosticMessage | undefined } {
|
||||
let errorInfo: DiagnosticMessageChain | undefined;
|
||||
const isCall = kind === SignatureKind.Call;
|
||||
const awaitedType = getAwaitedType(apparentType);
|
||||
const mightWorkWithAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
|
||||
const maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
|
||||
if (apparentType.flags & TypeFlags.Union) {
|
||||
const types = (apparentType as UnionType).types;
|
||||
let hasSignatures = false;
|
||||
@@ -22419,15 +22420,20 @@ namespace ts {
|
||||
typeToString(apparentType)
|
||||
);
|
||||
}
|
||||
return chainDiagnosticMessages(
|
||||
errorInfo,
|
||||
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
|
||||
);
|
||||
return {
|
||||
messageChain: chainDiagnosticMessages(
|
||||
errorInfo,
|
||||
isCall ? Diagnostics.This_expression_is_not_callable : Diagnostics.This_expression_is_not_constructable
|
||||
),
|
||||
relatedMessage: maybeMissingAwait ? Diagnostics.Did_you_forget_to_use_await : undefined,
|
||||
};
|
||||
}
|
||||
function invocationError(errorTarget: Node, apparentType: Type, kind: SignatureKind, relatedInformation?: DiagnosticRelatedInformation) {
|
||||
const diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, invocationErrorDetails(apparentType, kind));
|
||||
const { messageChain, relatedMessage: relatedInfo } = invocationErrorDetails(apparentType, kind);
|
||||
const diagnostic = createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
|
||||
if (relatedInfo) {
|
||||
addRelatedInfo(diagnostic, createDiagnosticForNode(errorTarget, relatedInfo));
|
||||
}
|
||||
if (isCallExpression(errorTarget.parent)) {
|
||||
const { start, length } = getDiagnosticSpanForCallNode(errorTarget.parent, /* doNotIncludeArguments */ true);
|
||||
diagnostic.start = start;
|
||||
@@ -22527,9 +22533,12 @@ namespace ts {
|
||||
|
||||
const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
||||
if (!callSignatures.length) {
|
||||
let errorInfo = invocationErrorDetails(apparentType, SignatureKind.Call);
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, headMessage);
|
||||
const diag = createDiagnosticForNodeFromMessageChain(node.expression, errorInfo);
|
||||
const errorDetails = invocationErrorDetails(apparentType, SignatureKind.Call);
|
||||
const messageChain = chainDiagnosticMessages(errorDetails.messageChain, headMessage);
|
||||
const diag = createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
|
||||
if (errorDetails.relatedMessage) {
|
||||
addRelatedInfo(diag, createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
|
||||
}
|
||||
diagnostics.add(diag);
|
||||
invocationErrorRecovery(apparentType, SignatureKind.Call, diag);
|
||||
return resolveErrorCall(node);
|
||||
@@ -23687,14 +23696,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage, missingAwaitDiagnostic: DiagnosticMessage): boolean {
|
||||
function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage): boolean {
|
||||
if (!isTypeAssignableTo(type, numberOrBigIntType)) {
|
||||
const awaitedType = getAwaitedType(type);
|
||||
errorAndMaybeSuggestAwait(
|
||||
operand,
|
||||
!!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType),
|
||||
diagnostic,
|
||||
missingAwaitDiagnostic);
|
||||
diagnostic);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -23892,8 +23900,7 @@ namespace ts {
|
||||
case SyntaxKind.PlusPlusToken:
|
||||
case SyntaxKind.MinusMinusToken:
|
||||
const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand),
|
||||
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type,
|
||||
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_Did_you_forget_to_use_await);
|
||||
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type);
|
||||
if (ok) {
|
||||
// run check only if former checks succeeded to avoid reporting cascading errors
|
||||
checkReferenceExpression(node.operand, Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access);
|
||||
@@ -23911,8 +23918,7 @@ namespace ts {
|
||||
const ok = checkArithmeticOperandType(
|
||||
node.operand,
|
||||
checkNonNullType(operandType, node.operand),
|
||||
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type,
|
||||
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_Did_you_forget_to_use_await);
|
||||
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type);
|
||||
if (ok) {
|
||||
// run check only if former checks succeeded to avoid reporting cascading errors
|
||||
checkReferenceExpression(node.operand, Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access);
|
||||
@@ -24304,8 +24310,8 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// otherwise just check each operand separately and report errors as normal
|
||||
const leftOk = checkArithmeticOperandType(left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_Did_you_forget_to_use_await);
|
||||
const rightOk = checkArithmeticOperandType(right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, Diagnostics.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);
|
||||
const leftOk = checkArithmeticOperandType(left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type);
|
||||
const rightOk = checkArithmeticOperandType(right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type);
|
||||
let resultType: Type;
|
||||
// If both are any or unknown, allow operation; assume it will resolve to number
|
||||
if ((isTypeAssignableToKind(leftType, TypeFlags.AnyOrUnknown) && isTypeAssignableToKind(rightType, TypeFlags.AnyOrUnknown)) ||
|
||||
@@ -24558,7 +24564,6 @@ namespace ts {
|
||||
errNode,
|
||||
wouldWorkWithAwait,
|
||||
Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2,
|
||||
Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2_Did_you_forget_to_use_await,
|
||||
tokenToString(operatorToken.kind),
|
||||
leftStr,
|
||||
rightStr,
|
||||
@@ -24583,7 +24588,6 @@ namespace ts {
|
||||
errNode,
|
||||
maybeMissingAwait,
|
||||
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap,
|
||||
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_Did_you_forget_to_use_await,
|
||||
typeName, leftStr, rightStr);
|
||||
}
|
||||
|
||||
@@ -27937,28 +27941,22 @@ namespace ts {
|
||||
// number and string input is allowed, we want to say that number is not an
|
||||
// array type or a string type.
|
||||
const yieldType = getIterationTypeOfIterable(use, IterationTypeKind.Yield, inputType, /*errorNode*/ undefined);
|
||||
const [defaultDiagnostic, missingAwaitDiagnostic]: [DiagnosticMessage, DiagnosticMessage | undefined] = !(use & IterationUse.AllowsStringInputFlag) || hasStringConstituent
|
||||
const [defaultDiagnostic, maybeMissingAwait]: [DiagnosticMessage, boolean] = !(use & IterationUse.AllowsStringInputFlag) || hasStringConstituent
|
||||
? downlevelIteration
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, Diagnostics.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]
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
|
||||
: yieldType
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, undefined]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type, Diagnostics.Type_0_is_not_an_array_type_Did_you_forget_to_use_await]
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type, true]
|
||||
: downlevelIteration
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, Diagnostics.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]
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
|
||||
: yieldType
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, undefined]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Did_you_forget_to_use_await];
|
||||
if (missingAwaitDiagnostic) {
|
||||
errorAndMaybeSuggestAwait(
|
||||
errorNode,
|
||||
!!getAwaitedTypeOfPromise(arrayType),
|
||||
defaultDiagnostic,
|
||||
missingAwaitDiagnostic,
|
||||
typeToString(arrayType));
|
||||
}
|
||||
else {
|
||||
error(errorNode, defaultDiagnostic, typeToString(arrayType));
|
||||
}
|
||||
? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
|
||||
: [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true];
|
||||
errorAndMaybeSuggestAwait(
|
||||
errorNode,
|
||||
maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType),
|
||||
defaultDiagnostic,
|
||||
typeToString(arrayType));
|
||||
}
|
||||
return hasStringConstituent ? stringType : undefined;
|
||||
}
|
||||
@@ -28257,10 +28255,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function reportTypeNotIterableError(errorNode: Node, type: Type, allowAsyncIterables: boolean): void {
|
||||
const [defaultDiagnostic, missingAwaitDiagnostic] = allowAsyncIterables
|
||||
? [Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator, Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_Did_you_forget_to_use_await]
|
||||
: [Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator, Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator_Did_you_forget_to_use_await];
|
||||
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), defaultDiagnostic, missingAwaitDiagnostic, typeToString(type));
|
||||
const message = allowAsyncIterables
|
||||
? Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
||||
: Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
||||
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2655,8 +2655,7 @@
|
||||
},
|
||||
"Cannot iterate value because the 'next' method of its iterator expects type '{1}', but for-of will always send '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2763
|
||||
},
|
||||
"code": 77 },
|
||||
"Cannot iterate value because the 'next' method of its iterator expects type '{1}', but array spread will always send '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2764
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(11,9): error TS2766: 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'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(12,5): error TS2765: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(13,5): error TS2763: Operator '+' cannot be applied to types 'number' and 'Promise<number>'. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(14,5): error TS2763: Operator '>' cannot be applied to types 'number' and 'Promise<number>'. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(15,5): error TS2764: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(16,7): error TS2764: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(17,5): error TS2776: This condition will always return 'false' since the types 'number' and 'Promise<number>' have no overlap. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(18,9): error TS2769: Type 'Promise<string[]>' is not an array type. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(19,21): error TS2770: Type 'Promise<string[]>' is not an array type or a string type. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(11,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(12,5): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(13,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'Promise<number>'.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(14,5): error TS2365: Operator '>' cannot be applied to types 'number' and 'Promise<number>'.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(15,5): error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(16,7): error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(17,5): error TS2367: This condition will always return 'false' since the types 'number' and 'Promise<number>' have no overlap.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(18,9): error TS2461: Type 'Promise<string[]>' is not an array type.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(19,21): error TS2495: Type 'Promise<string[]>' is not an array type or a string type.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(20,12): error TS2345: Argument of type 'Promise<number>' is not assignable to parameter of type 'number'.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(21,11): error TS2570: Property 'prop' does not exist on type 'Promise<{ prop: string; }>'. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(23,27): error TS2770: Type 'Promise<string[]>' is not an array type or a string type. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(24,5): error TS2774: This expression is not callable. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(23,27): error TS2495: Type 'Promise<string[]>' is not an array type or a string type.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(24,5): error TS2349: This expression is not callable.
|
||||
Type 'Promise<() => void>' has no call signatures.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(25,5): error TS2774: This expression is not callable. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(25,5): error TS2349: This expression is not callable.
|
||||
Not all constituents of type 'Promise<() => void> | (() => void)' are callable.
|
||||
Type 'Promise<() => void>' has no call signatures.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(26,9): error TS2775: This expression is not constructable. Did you forget to use 'await'?
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(26,9): error TS2351: This expression is not constructable.
|
||||
Type 'Promise<new () => any>' has no construct signatures.
|
||||
tests/cases/compiler/operationsAvailableOnPromisedType.ts(27,5): error TS2349: This expression is not callable.
|
||||
Type 'Promise<number>' has no call signatures.
|
||||
@@ -34,55 +34,68 @@ tests/cases/compiler/operationsAvailableOnPromisedType.ts(27,5): error TS2349: T
|
||||
// All errors
|
||||
a | b;
|
||||
~
|
||||
!!! error TS2766: 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'?
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:11:9: Did you forget to use 'await'?
|
||||
b | a;
|
||||
~
|
||||
!!! error TS2765: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. Did you forget to use 'await'?
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:12:5: Did you forget to use 'await'?
|
||||
a + b;
|
||||
~~~~~
|
||||
!!! error TS2763: Operator '+' cannot be applied to types 'number' and 'Promise<number>'. Did you forget to use 'await'?
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'Promise<number>'.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:13:5: Did you forget to use 'await'?
|
||||
a > b;
|
||||
~~~~~
|
||||
!!! error TS2763: Operator '>' cannot be applied to types 'number' and 'Promise<number>'. Did you forget to use 'await'?
|
||||
!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'Promise<number>'.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:14:5: Did you forget to use 'await'?
|
||||
b++;
|
||||
~
|
||||
!!! error TS2764: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. Did you forget to use 'await'?
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:15:5: Did you forget to use 'await'?
|
||||
--b;
|
||||
~
|
||||
!!! error TS2764: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type. Did you forget to use 'await'?
|
||||
!!! error TS2356: An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:16:7: Did you forget to use 'await'?
|
||||
a === b;
|
||||
~~~~~~~
|
||||
!!! error TS2776: This condition will always return 'false' since the types 'number' and 'Promise<number>' have no overlap. Did you forget to use 'await'?
|
||||
!!! error TS2367: This condition will always return 'false' since the types 'number' and 'Promise<number>' have no overlap.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:17:5: Did you forget to use 'await'?
|
||||
[...c];
|
||||
~
|
||||
!!! error TS2769: Type 'Promise<string[]>' is not an array type. Did you forget to use 'await'?
|
||||
!!! error TS2461: Type 'Promise<string[]>' is not an array type.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:18:9: Did you forget to use 'await'?
|
||||
for (const s of c) {
|
||||
~
|
||||
!!! error TS2770: Type 'Promise<string[]>' is not an array type or a string type. Did you forget to use 'await'?
|
||||
!!! error TS2495: Type 'Promise<string[]>' is not an array type or a string type.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:19:21: Did you forget to use 'await'?
|
||||
fn(b, b, c, d, e, f, g);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'Promise<number>' is not assignable to parameter of type 'number'.
|
||||
!!! related TS2777 tests/cases/compiler/operationsAvailableOnPromisedType.ts:20:12: Did you forget to use 'await'?
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:20:12: Did you forget to use 'await'?
|
||||
d.prop;
|
||||
~~~~
|
||||
!!! error TS2570: Property 'prop' does not exist on type 'Promise<{ prop: string; }>'. Did you forget to use 'await'?
|
||||
}
|
||||
for await (const s of c) {}
|
||||
~
|
||||
!!! error TS2770: Type 'Promise<string[]>' is not an array type or a string type. Did you forget to use 'await'?
|
||||
!!! error TS2495: Type 'Promise<string[]>' is not an array type or a string type.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:23:27: Did you forget to use 'await'?
|
||||
e();
|
||||
~
|
||||
!!! error TS2774: This expression is not callable. Did you forget to use 'await'?
|
||||
!!! error TS2774: Type 'Promise<() => void>' has no call signatures.
|
||||
!!! error TS2349: This expression is not callable.
|
||||
!!! error TS2349: Type 'Promise<() => void>' has no call signatures.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:24:5: Did you forget to use 'await'?
|
||||
f();
|
||||
~
|
||||
!!! error TS2774: This expression is not callable. Did you forget to use 'await'?
|
||||
!!! error TS2774: Not all constituents of type 'Promise<() => void> | (() => void)' are callable.
|
||||
!!! error TS2774: Type 'Promise<() => void>' has no call signatures.
|
||||
!!! error TS2349: This expression is not callable.
|
||||
!!! error TS2349: Not all constituents of type 'Promise<() => void> | (() => void)' are callable.
|
||||
!!! error TS2349: Type 'Promise<() => void>' has no call signatures.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:25:5: Did you forget to use 'await'?
|
||||
new g();
|
||||
~
|
||||
!!! error TS2775: This expression is not constructable. Did you forget to use 'await'?
|
||||
!!! error TS2775: Type 'Promise<new () => any>' has no construct signatures.
|
||||
!!! error TS2351: This expression is not constructable.
|
||||
!!! error TS2351: Type 'Promise<new () => any>' has no construct signatures.
|
||||
!!! related TS2763 tests/cases/compiler/operationsAvailableOnPromisedType.ts:26:9: Did you forget to use 'await'?
|
||||
b();
|
||||
~
|
||||
!!! error TS2349: This expression is not callable.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(2,12): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(8,12): error TS2780: Type 'Promise<number[]>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. Did you forget to use 'await'?
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(8,12): error TS2504: Type 'Promise<number[]>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncGenerator<string, void, unknown>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
Type 'AsyncGenerator<string, void, unknown>' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
Types of property 'next' are incompatible.
|
||||
@@ -71,7 +71,8 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(
|
||||
async function * inferReturnType3() {
|
||||
yield* Promise.resolve([1, 2]);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2780: Type 'Promise<number[]>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. Did you forget to use 'await'?
|
||||
!!! error TS2504: Type 'Promise<number[]>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
|
||||
!!! related TS2789 tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts:8:12: Did you forget to use 'await'?
|
||||
}
|
||||
const assignability1: () => AsyncIterableIterator<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Reference in New Issue
Block a user