Fix await code action crashes when await is not in a function (#22623)

Fixes #22614
This commit is contained in:
Matt Bierner
2018-03-16 11:53:17 -07:00
committed by Andy
parent b9f60566d0
commit 9774cd5eb5
2 changed files with 9 additions and 0 deletions

View File

@@ -36,6 +36,10 @@ namespace ts.codefix {
function getNodes(sourceFile: SourceFile, start: number): { insertBefore: Node, returnType: TypeNode | undefined } | undefined {
const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
const containingFunction = getContainingFunction(token);
if (!containingFunction) {
return;
}
let insertBefore: Node | undefined;
switch (containingFunction.kind) {
case SyntaxKind.MethodDeclaration:

View File

@@ -0,0 +1,5 @@
/// <reference path='fourslash.ts' />
////await a
verify.not.codeFixAvailable();