Support completions after 'async' in object literal (#27250)

This commit is contained in:
Andy 2018-09-26 11:22:27 -07:00 committed by GitHub
parent d4d947e488
commit b3dd471584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -1713,6 +1713,9 @@ namespace ts.Completions {
break;
case SyntaxKind.AsteriskToken:
return isMethodDeclaration(parent) ? tryCast(parent.parent, isObjectLiteralExpression) : undefined;
case SyntaxKind.Identifier:
return (contextToken as Identifier).text === "async" && isShorthandPropertyAssignment(contextToken.parent)
? contextToken.parent.parent : undefined;
}
}
@ -1928,7 +1931,6 @@ namespace ts.Completions {
// Previous token may have been a keyword that was converted to an identifier.
switch (keywordForNode(contextToken)) {
case SyntaxKind.AbstractKeyword:
case SyntaxKind.AsyncKeyword:
case SyntaxKind.ClassKeyword:
case SyntaxKind.ConstKeyword:
case SyntaxKind.DeclareKeyword:
@ -1943,6 +1945,8 @@ namespace ts.Completions {
case SyntaxKind.VarKeyword:
case SyntaxKind.YieldKeyword:
return true;
case SyntaxKind.AsyncKeyword:
return isPropertyDeclaration(contextToken.parent);
}
return isDeclarationName(contextToken)

View File

@ -0,0 +1,5 @@
/// <reference path="fourslash.ts" />
////const x: { m(): Promise<void> } = { async /**/ };
verify.completions({ marker: "", exact: "m" });