Fix TypeScript function detection and argument counting - #1768
Merged
Conversation
This reverts commit b614ebc.
Contributor
squid-protocol
force-pushed
the
ts-fixes-pr
branch
from
August 16, 2026 23:21
3216988 to
6b6b98b
Compare
squid-protocol
force-pushed
the
ts-fixes-pr
branch
from
August 16, 2026 23:46
6b6b98b to
c01f84e
Compare
This was referenced Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1753, #1749, #1716, #1715, #1714, #1713, #1712, #1711, #1706, #1705.
Summary
This PR represents a major overhaul of the TypeScript
func_startregex and associated structural extraction logic, addressing several critical precision and recall bugs. Through a comprehensive audit against Tree-sitter usingtests/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
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., capturingBinreduce: <A, B>(...) => B = ...). Now, it safely consumes the entire optional type annotation and correctly captures the variable name.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.[Symbol.asyncIterator]() { ... }and other bracket-notation computed property names.constvariables containing arrow functions nested deep inside scopes.const _alt: Alt2<URI>['alt'] = (fa, that) => ....Audit Enhancements
tree_sitter_accuracy_audit.pyground truth definition for TypeScript to extract names forarrow_functionnodes withinpublic_field_definitions (class fields), and added support forfunction_signature/method_signaturetypes 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.