Skip to content

Commit 573bfec

Browse files
committed
Merge remote-tracking branch 'upstream/master' into dontEmitNodeModules
2 parents d8047b6 + 7b77f6b commit 573bfec

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15388,7 +15388,7 @@ namespace ts {
1538815388

1538915389
function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean {
1539015390
const unwrappedReturnType = isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType;
15391-
return maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any);
15391+
return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any);
1539215392
}
1539315393

1539415394
function checkReturnStatement(node: ReturnStatement) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error TS2318: Cannot find global type 'Promise'.
2+
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher.
3+
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS1057: An async function or method must have a valid awaitable return type.
4+
tests/cases/compiler/asyncFunctionNoReturnType.ts(1,1): error TS7030: Not all code paths return a value.
5+
tests/cases/compiler/asyncFunctionNoReturnType.ts(2,9): error TS2304: Cannot find name 'window'.
6+
tests/cases/compiler/asyncFunctionNoReturnType.ts(3,9): error TS7030: Not all code paths return a value.
7+
8+
9+
!!! error TS2318: Cannot find global type 'Promise'.
10+
==== tests/cases/compiler/asyncFunctionNoReturnType.ts (5 errors) ====
11+
async () => {
12+
~~~~~
13+
!!! error TS1311: Async functions are only available when targeting ECMAScript 2015 or higher.
14+
~~~~~~~~~~~~~
15+
!!! error TS1057: An async function or method must have a valid awaitable return type.
16+
~~~~~~~~~~~~~
17+
!!! error TS7030: Not all code paths return a value.
18+
if (window)
19+
~~~~~~
20+
!!! error TS2304: Cannot find name 'window'.
21+
return;
22+
~~~~~~~
23+
!!! error TS7030: Not all code paths return a value.
24+
}
25+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//// [asyncFunctionNoReturnType.ts]
2+
async () => {
3+
if (window)
4+
return;
5+
}
6+
7+
8+
//// [asyncFunctionNoReturnType.js]
9+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10+
return new (P || (P = Promise))(function (resolve, reject) {
11+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12+
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
13+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
14+
step((generator = generator.apply(thisArg, _arguments)).next());
15+
});
16+
};
17+
(function () __awaiter(this, void 0, void 0, function* () {
18+
if (window)
19+
return;
20+
}));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @noImplicitReturns: true
2+
async () => {
3+
if (window)
4+
return;
5+
}

0 commit comments

Comments
 (0)