You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
15956
15961
// return type of the body should be unwrapped to its awaited type, which should be wrapped in
15957
15962
// the native Promise<T> type by the caller.
15958
-
type = checkAwaitedType(type, func);
15963
+
type = checkAwaitedType(type, func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
Copy file name to clipboardExpand all lines: src/compiler/diagnosticMessages.json
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,7 @@
175
175
"category": "Error",
176
176
"code": 1057
177
177
},
178
-
"Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.": {
178
+
"The return type of an async function must either be a valid promise or must not contain a callable 'then' member.": {
179
179
"category": "Error",
180
180
"code": 1058
181
181
},
@@ -867,6 +867,18 @@
867
867
"category": "Error",
868
868
"code": 1319
869
869
},
870
+
"Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.": {
871
+
"category": "Error",
872
+
"code": 1320
873
+
},
874
+
"Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member.": {
875
+
"category": "Error",
876
+
"code": 1321
877
+
},
878
+
"Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.": {
Type '() => void' is not assignable to type '<TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => PromiseLike<TResult1 | TResult2>'.
10
10
Type 'void' is not assignable to type 'PromiseLike<any>'.
11
-
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
12
-
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
11
+
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(17,16): error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member.
12
+
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts(23,25): error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
async function fn13() { return thenable; } // error
49
49
~~~~
50
-
!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
50
+
!!! error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member.
51
51
async function fn14() { await 1; } // valid: Promise<void>
52
52
async function fn15() { await null; } // valid: Promise<void>
53
53
async function fn16() { await undefined; } // valid: Promise<void>
54
54
async function fn17() { await a; } // valid: Promise<void>
55
55
async function fn18() { await obj; } // valid: Promise<void>
56
56
async function fn19() { await thenable; } // error
57
57
~~~~~~~~~~~~~~
58
-
!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
58
+
!!! error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise<T> type.
4
4
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise<T> type.
5
5
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise<T> type.
6
-
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(17,16): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
7
-
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(23,25): error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
6
+
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(17,16): error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member.
7
+
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(23,25): error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
async function fn13() { return thenable; } // error
38
38
~~~~
39
-
!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
39
+
!!! error TS1058: The return type of an async function must either be a valid promise or must not contain a callable 'then' member.
40
40
async function fn14() { await 1; } // valid: Promise<void>
41
41
async function fn15() { await null; } // valid: Promise<void>
42
42
async function fn16() { await undefined; } // valid: Promise<void>
43
43
async function fn17() { await a; } // valid: Promise<void>
44
44
async function fn18() { await obj; } // valid: Promise<void>
45
45
async function fn19() { await thenable; } // error
46
46
~~~~~~~~~~~~~~
47
-
!!! error TS1058: Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.
47
+
!!! error TS1320: Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.
0 commit comments