Skip to content

Commit b3dd471

Browse files
author
Andy
authored
Support completions after 'async' in object literal (microsoft#27250)
1 parent d4d947e commit b3dd471

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/services/completions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,9 @@ namespace ts.Completions {
17131713
break;
17141714
case SyntaxKind.AsteriskToken:
17151715
return isMethodDeclaration(parent) ? tryCast(parent.parent, isObjectLiteralExpression) : undefined;
1716+
case SyntaxKind.Identifier:
1717+
return (contextToken as Identifier).text === "async" && isShorthandPropertyAssignment(contextToken.parent)
1718+
? contextToken.parent.parent : undefined;
17161719
}
17171720
}
17181721

@@ -1928,7 +1931,6 @@ namespace ts.Completions {
19281931
// Previous token may have been a keyword that was converted to an identifier.
19291932
switch (keywordForNode(contextToken)) {
19301933
case SyntaxKind.AbstractKeyword:
1931-
case SyntaxKind.AsyncKeyword:
19321934
case SyntaxKind.ClassKeyword:
19331935
case SyntaxKind.ConstKeyword:
19341936
case SyntaxKind.DeclareKeyword:
@@ -1943,6 +1945,8 @@ namespace ts.Completions {
19431945
case SyntaxKind.VarKeyword:
19441946
case SyntaxKind.YieldKeyword:
19451947
return true;
1948+
case SyntaxKind.AsyncKeyword:
1949+
return isPropertyDeclaration(contextToken.parent);
19461950
}
19471951

19481952
return isDeclarationName(contextToken)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////const x: { m(): Promise<void> } = { async /**/ };
4+
5+
verify.completions({ marker: "", exact: "m" });

0 commit comments

Comments
 (0)