Skip to content

Commit 3435727

Browse files
committed
Fix #11396: Make error message referene Promise explicitly
1 parent 859aa30 commit 3435727

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13073,7 +13073,7 @@ namespace ts {
1307313073
function createPromiseReturnType(func: FunctionLikeDeclaration, promisedType: Type) {
1307413074
const promiseType = createPromiseType(promisedType);
1307513075
if (promiseType === emptyObjectType) {
13076-
error(func, Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type);
13076+
error(func, Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option);
1307713077
return unknownType;
1307813078
}
1307913079

src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,10 @@
19671967
"category": "Error",
19681968
"code": 2696
19691969
},
1970+
"An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": {
1971+
"category": "Error",
1972+
"code": 2697
1973+
},
19701974

19711975
"Import declaration '{0}' is using private name '{1}'.": {
19721976
"category": "Error",

tests/baselines/reference/asyncFunctionNoReturnType.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error TS2318: Cannot find global type 'Promise'.
2-
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1057: An async function or method must have a valid awaitable return type.
2+
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.
33
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value.
44
tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'.
55
tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all code paths return a value.
@@ -9,7 +9,7 @@ tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all co
99
==== tests/cases/compiler/asyncFunctionNoReturnType.ts (4 errors) ====
1010
async () => {
1111
~~~~~~~~~~~~~
12-
!!! error TS1057: An async function or method must have a valid awaitable return type.
12+
!!! error TS2697: An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.
1313
~~~~~~~~~~~~~
1414
!!! error TS7030: Not all code paths return a value.
1515
if (window)

0 commit comments

Comments
 (0)