mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 07:21:18 -05:00
Fix await code action crashes when await is not in a function (#22623)
Fixes #22614
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////await a
|
||||
|
||||
verify.not.codeFixAvailable();
|
||||
Reference in New Issue
Block a user