From 28b39d97a3efd1d3b8f7610985bb3ba5bcb2cdde Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 24 Aug 2020 10:41:04 -0700 Subject: [PATCH] Only contextually type unused 'await' --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 819cd98f6fd..79913281d82 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23193,7 +23193,7 @@ namespace ts { if (node === right) { return getContextualType(binaryExpression, contextFlags); } - else if (!(contextFlags! & ContextFlags.SkipBindingPatternsAndUnusedExpressions)) { + else if (isAwaitExpression(skipParentheses(node)) && !(contextFlags! & ContextFlags.SkipBindingPatternsAndUnusedExpressions)) { return voidType; } return undefined; @@ -23610,13 +23610,13 @@ namespace ts { return getContextualJsxElementAttributesType(parent, contextFlags); case SyntaxKind.ExpressionStatement: case SyntaxKind.VoidExpression: - if (!(contextFlags! & ContextFlags.SkipBindingPatternsAndUnusedExpressions)) { + if (isAwaitExpression(skipParentheses(node)) && !(contextFlags! & ContextFlags.SkipBindingPatternsAndUnusedExpressions)) { return voidType; } break; case SyntaxKind.ForStatement: { const forStatement = parent as ForStatement; - if (!(contextFlags! & ContextFlags.SkipBindingPatternsAndUnusedExpressions) && (node === forStatement.initializer || node === forStatement.incrementor)) { + if (isAwaitExpression(skipParentheses(node)) && !(contextFlags! & ContextFlags.SkipBindingPatternsAndUnusedExpressions) && (node === forStatement.initializer || node === forStatement.incrementor)) { return voidType; } break;