Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(ingestion): capture TypeScript #private class members and calls (#1721)

Sloee9d1ece1628b
diff --git a/packages/core/src/repowise/core/ingestion/queries/typescript.scm b/packages/core/src/repowise/core/ingestion/queries/typescript.scm
index 0fb24fb0f..08c1d51c0 100644
--- a/packages/core/src/repowise/core/ingestion/queries/typescript.scm
+++ b/packages/core/src/repowise/core/ingestion/queries/typescript.scm
@@ -50,6 +50,12 @@
parameters: (formal_parameters) @symbol.params
) @symbol.def
+; Private method inside class body (ECMAScript #private members)
+(method_definition
+ name: (private_property_identifier) @symbol.name
+ parameters: (formal_parameters) @symbol.params
+) @symbol.def
+
; Arrow function assigned to const/let: const foo = (...) => { }
(lexical_declaration
(variable_declarator
@@ -226,7 +232,7 @@
(call_expression
function: (member_expression
object: [(identifier) (this)] @call.receiver
- property: (property_identifier) @call.target
+ property: [(property_identifier) (private_property_identifier)] @call.target
)
arguments: (arguments) @call.arguments
) @call.site
diff --git a/tests/unit/ingestion/parser/test_typescript.py b/tests/unit/ingestion/parser/test_typescript.py
index e9012d448..859793779 100644
--- a/tests/unit/ingestion/parser/test_typescript.py
+++ b/tests/unit/ingestion/parser/test_typescript.py
@@ -630,3 +630,36 @@ export const handler = onCall(async () => 1);
def test_class_and_function_expression_bindings_are_indexed(self, parser: ASTParser) -> None:
assert {"KlassExpr", "fnExpr"} <= self._names(parser)
+
+
+class TestTypeScriptPrivateMembers:
+ """ECMAScript #private class members should produce a symbol and a call site.
+
+ Regression for #1715: tree-sitter spells ``#foo`` as
+ ``private_property_identifier``, which the symbol and member-call query
+ patterns did not accept, so private methods were invisible at both ends.
+ """
+
+ def test_private_method_produces_symbol(self, parser: ASTParser) -> None:
+ fi = _make_file_info("src/counter.ts", "typescript")
+ src = b"""\
+class Counter {
+ #count = 0;
+ #increment() { this.#count++; }
+ inc() { this.#increment(); return this.#count; }
+}"""
+ result = parser.parse_file(fi, src)
+ method_names = [s.name for s in result.symbols if s.kind == "method"]
+ assert "#increment" in method_names
+
+ def test_private_method_call_produces_call_site(self, parser: ASTParser) -> None:
+ fi = _make_file_info("src/counter.ts", "typescript")
+ src = b"""\
+class Counter {
+ #count = 0;
+ #increment() { this.#count++; }
+ inc() { this.#increment(); return this.#count; }
+}"""
+ result = parser.parse_file(fi, src)
+ call_targets = [c.target_name for c in result.calls]
+ assert "#increment" in call_targets