diff --git a/src/services/completions.ts b/src/services/completions.ts index 471d8e4c142..9de0d2cb761 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -877,7 +877,7 @@ namespace ts.Completions { // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && (isIdentifier(contextToken) || isKeyword(contextToken.kind))) { + if (contextToken && position <= contextToken.end && (isIdentifierOrPrivateIdentifier(contextToken) || isKeyword(contextToken.kind))) { const start = timestamp(); contextToken = findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined)!; // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (timestamp() - start)); diff --git a/tests/cases/fourslash/completionsECMAPrivateMember.ts b/tests/cases/fourslash/completionsECMAPrivateMember.ts new file mode 100644 index 00000000000..16735cc93cc --- /dev/null +++ b/tests/cases/fourslash/completionsECMAPrivateMember.ts @@ -0,0 +1,21 @@ +/// + +// @target: esnext + +////class K { +//// #value: number; +//// +//// foo() { +//// this.#va/**/ +//// } +////} + +verify.completions({ + marker: "", + exact: [{ + name: "#value", + insertText: undefined + }, { + name: "foo" + }] +});