Fix isNewIdentifierLocation after async (#46485)
This commit is contained in:
parent
ce676d0963
commit
de1ac8191e
|
@ -2209,8 +2209,9 @@ namespace ts.Completions {
|
|||
function isNewIdentifierDefinitionLocation(): boolean {
|
||||
if (contextToken) {
|
||||
const containingNodeKind = contextToken.parent.kind;
|
||||
const tokenKind = keywordForNode(contextToken);
|
||||
// Previous token may have been a keyword that was converted to an identifier.
|
||||
switch (keywordForNode(contextToken)) {
|
||||
switch (tokenKind) {
|
||||
case SyntaxKind.CommaToken:
|
||||
return containingNodeKind === SyntaxKind.CallExpression // func( a, |
|
||||
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
|
||||
|
@ -2254,10 +2255,13 @@ namespace ts.Completions {
|
|||
case SyntaxKind.TemplateMiddle:
|
||||
return containingNodeKind === SyntaxKind.TemplateSpan; // `aa ${10} dd ${|
|
||||
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
return containingNodeKind === SyntaxKind.PropertyDeclaration; // class A{ public |
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
return containingNodeKind === SyntaxKind.MethodDeclaration // const obj = { async c|()
|
||||
|| containingNodeKind === SyntaxKind.ShorthandPropertyAssignment; // const obj = { async c|
|
||||
}
|
||||
|
||||
if (isClassMemberCompletionKeyword(tokenKind)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
25
tests/cases/fourslash/completionsAsyncMethodDeclaration.ts
Normal file
25
tests/cases/fourslash/completionsAsyncMethodDeclaration.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const obj = {
|
||||
//// a() {},
|
||||
//// async b/*1*/
|
||||
//// };
|
||||
//// const obj2 = {
|
||||
//// async /*2*/
|
||||
//// };
|
||||
//// class Foo {
|
||||
//// async b/*3*/
|
||||
//// }
|
||||
//// class Foo2 {
|
||||
//// async /*4*/
|
||||
//// }
|
||||
//// class Bar {
|
||||
//// static async b/*5*/
|
||||
//// }
|
||||
|
||||
test.markerNames().forEach(marker => {
|
||||
verify.completions({
|
||||
marker,
|
||||
isNewIdentifierLocation: true
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue