From 1fd9de321473909199929faf38cbfcd181a13815 Mon Sep 17 00:00:00 2001 From: uhyo Date: Thu, 2 May 2019 01:57:41 +0900 Subject: [PATCH] do not suggest to mark constructor 'async' --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 728c10dcf5637..19f4c3b055d3f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23093,7 +23093,7 @@ namespace ts { const span = getSpanOfTokenAtPosition(sourceFile, node.pos); const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.await_expression_is_only_allowed_within_an_async_function); const func = getContainingFunction(node); - if (func) { + if (func && func.kind !== SyntaxKind.Constructor) { Debug.assert((getFunctionFlags(func) & FunctionFlags.Async) === 0, "Enclosing function should never be an async function."); const relatedInfo = createDiagnosticForNode(func, Diagnostics.Did_you_mean_to_mark_this_function_as_async); addRelatedInfo(diagnostic, relatedInfo); @@ -31603,7 +31603,7 @@ namespace ts { if (!hasParseDiagnostics(sourceFile)) { const diagnostic = createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); const func = getContainingFunction(forInOrOfStatement); - if (func) { + if (func && func.kind !== SyntaxKind.Constructor) { Debug.assert((getFunctionFlags(func) & FunctionFlags.Async) === 0, "Enclosing function should never be an async function."); const relatedInfo = createDiagnosticForNode(func, Diagnostics.Did_you_mean_to_mark_this_function_as_async); addRelatedInfo(diagnostic, relatedInfo);