From cc048ac89822932338eeccda347756b98d7399fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 19 Sep 2026 14:47:17 +0000 Subject: [PATCH 1/2] Initial plan From f91355104b9f258f65328dbe498e1e15777e050d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 19 Sep 2026 14:52:18 +0000 Subject: [PATCH 2/2] Classify private identifiers as semantic tokens Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- ...rnClassificationPrivateIdentifiers_test.go | 32 +++++++++++++++++++ tsc/internal/ls/semantictokens.go | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tsc/internal/fourslash/tests/semanticModernClassificationPrivateIdentifiers_test.go diff --git a/tsc/internal/fourslash/tests/semanticModernClassificationPrivateIdentifiers_test.go b/tsc/internal/fourslash/tests/semanticModernClassificationPrivateIdentifiers_test.go new file mode 100644 index 0000000000000..5f70ffde64b63 --- /dev/null +++ b/tsc/internal/fourslash/tests/semanticModernClassificationPrivateIdentifiers_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/TypeScript/tsc/internal/fourslash" + "github.com/microsoft/TypeScript/tsc/internal/testutil" +) + +func TestSemanticModernClassificationPrivateIdentifiers(t *testing.T) { + t.Parallel() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + #privateField = 1; + #privateMethod() {} + + test() { + this.#privateField; + this.#privateMethod(); + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifySemanticTokens(t, []fourslash.SemanticToken{ + {Type: "class.declaration", Text: "Foo"}, + {Type: "property.declaration", Text: "#privateField"}, + {Type: "method.declaration", Text: "#privateMethod"}, + {Type: "method.declaration", Text: "test"}, + {Type: "property", Text: "#privateField"}, + {Type: "method", Text: "#privateMethod"}, + }) +} diff --git a/tsc/internal/ls/semantictokens.go b/tsc/internal/ls/semantictokens.go index 4213c9016bc5d..e5fe386a36183 100644 --- a/tsc/internal/ls/semantictokens.go +++ b/tsc/internal/ls/semantictokens.go @@ -253,7 +253,7 @@ func (l *LanguageService) collectSemanticTokensInRange(ctx context.Context, c *c inJSXElement = false } - if ast.IsIdentifier(node) && node.Text() != "" && !inJSXElement && !isInImportClause(node) && !isInfinityOrNaNString(node.Text()) { + if (ast.IsIdentifier(node) || ast.IsPrivateIdentifier(node)) && node.Text() != "" && !inJSXElement && !isInImportClause(node) && !isInfinityOrNaNString(node.Text()) { symbol := c.GetSymbolAtLocation(node) if symbol != nil { // Resolve aliases