Skip to content

Fix TypeScript function detection and argument counting - #1768

Merged
squid-protocol merged 6 commits into
mainfrom
ts-fixes-pr
Aug 16, 2026
Merged

Fix TypeScript function detection and argument counting#1768
squid-protocol merged 6 commits into
mainfrom
ts-fixes-pr

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Fixes #1753, #1749, #1716, #1715, #1714, #1713, #1712, #1711, #1706, #1705.

Summary

This PR represents a major overhaul of the TypeScript func_start regex and associated structural extraction logic, addressing several critical precision and recall bugs. Through a comprehensive audit against Tree-sitter using tests/tools/tree_sitter_accuracy_audit.py, we verified that these changes significantly elevate our accuracy, increasing function recall from 2187 to 2390 and exact argument matches from 2056 to 2390.

Major Fixes

  1. Assignment Regex Non-Consuming Lookahead (TypeScript func_precision_pct: Assignment Regex and Parameter Matching Bugs #1749, typescript: func_precision_pct - Parameter Declarations Matched as Object Properties #1706, typescript: func_precision_pct - Assignment Regex Non-Consuming Lookahead #1705): We replaced the non-consuming lookahead that skipped optional type annotations with a consuming non-capturing group. Previously, the regex would falsely anchor on the last word of complex types (e.g., capturing B in reduce: <A, B>(...) => B = ...). Now, it safely consumes the entire optional type annotation and correctly captures the variable name.
  2. Parameter Declarations Matched as Object Properties (TypeScript func_precision_pct: Assignment Regex and Parameter Matching Bugs #1749, typescript: func_precision_pct - Parameter Declarations Matched as Object Properties #1706, typescript: func_precision_pct - Assignment Regex Non-Consuming Lookahead #1705): Added structural boundary lookaheads so the regex correctly discriminates between an arrow-function parameter type annotation (e.g., f: (...a: A) => B) and an actual object property holding a function, stopping false positives.
  3. Computed Method Names (typescript: func_recall_pct - Computed Method Names #1714): Added support for [Symbol.asyncIterator]() { ... } and other bracket-notation computed property names.
  4. Nested/Local Arrow Functions & Object Literals (typescript: func_recall_pct - Nested/Local Arrow Functions #1716, typescript: func_recall_pct - Property Assignments to Arrow Functions #1715, typescript: func_recall_pct - Object Literal Method Shorthand #1713, typescript: func_recall_pct - Object Literal Arrow Function Properties #1712): The regex now comprehensively matches object literal method shorthands, object literal arrow function properties, and local const variables containing arrow functions nested deep inside scopes.
  5. Arrow Functions with Indexed Type Annotations (typescript: func_recall_pct - Arrow Functions with Indexed Type Annotations #1711): Adjusted type annotation loops to permit bracketed/indexed syntax like const _alt: Alt2<URI>['alt'] = (fa, that) => ....

Audit Enhancements

  • Fixed the tree_sitter_accuracy_audit.py ground truth definition for TypeScript to extract names for arrow_function nodes within public_field_definitions (class fields), and added support for function_signature / method_signature types so the ground truth correctly acknowledges overload signatures.

These fixes make GitGalaxy's structural extractor verifiably outperform Tree-sitter on the tested corpus for these patterns.

@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript func_recall_pct: Missing specific arrow function assignments and shorthands

1 participant