diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5afdef09e45..84660c65b4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16493,7 +16493,6 @@ namespace ts { // } // - // TODO(rbuckton): Verify whether we need to call getApparentType. See checkNonThenableType in master const thenFunction = getTypeOfPropertyOfType(type, "then"); const thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray; if (thenSignatures.length > 0) { @@ -16600,7 +16599,7 @@ namespace ts { if (type.id === promisedType.id || indexOf(awaitedTypeStack, promisedType.id) >= 0) { // Verify that we don't have a bad actor in the form of a promise whose // promised type is the same as the promise type, or a mutually recursive - // promise. If so, we returnundefined as we cannot guess the shape. If this + // promise. If so, we return undefined as we cannot guess the shape. If this // were the actual case in the JavaScript, this Promise would never resolve. // // An example of a bad actor with a singly-recursive promise type might @@ -16664,15 +16663,14 @@ namespace ts { // of a runtime problem. If the user wants to return this value from an async // function, they would need to wrap it in some other value. If they want it to // be treated as a promise, they can cast to . - const widenedType = getWidenedType(type); - if (isThenableType(widenedType)) { + if (isThenableType(type)) { if (errorNode) { error(errorNode, Diagnostics.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); } return undefined; } - return typeAsAwaitable.awaitedTypeOfType = widenedType; + return typeAsAwaitable.awaitedTypeOfType = type; } /** diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index 5d300f44934..42ca685e295 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -262,8 +262,7 @@ namespace ts { function forEachLeadingCommentToEmit(pos: number, cb: (commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) => void) { // Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments - if ((containerPos === -1 || pos !== containerPos) /* && !leadingCommentPositions[pos] */) { - // leadingCommentPositions[pos] = true; + if ((containerPos === -1 || pos !== containerPos)) { if (hasDetachedComments(pos)) { forEachLeadingCommentWithoutDetachedComments(cb); } @@ -275,8 +274,7 @@ namespace ts { function forEachTrailingCommentToEmit(end: number, cb: (commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) => void) { // Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments - if ((containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd)) /*&& !trailingCommentPositions[end] */) { - // trailingCommentPositions[end] = true; + if ((containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) { forEachTrailingCommentRange(currentText, end, cb); } } diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types index 30220ca2ab6..24420e11d54 100644 --- a/tests/baselines/reference/castOfAwait.types +++ b/tests/baselines/reference/castOfAwait.types @@ -18,7 +18,7 @@ async function f() { >0 : 0 await void typeof void await 0; ->await void typeof void await 0 : any +>await void typeof void await 0 : undefined >void typeof void await 0 : undefined > typeof void await 0 : string >typeof void await 0 : string