fix(js-ts): reference functions consumed via casts, currying, member assignment, call args, param defaults, and shorthand methods#667
Conversation
…assignment, call args, param defaults, and shorthand methods
|
@greptile review |
Greptile SummaryThis PR expands JS/TS call-graph reference detection for callable values consumed through syntax that was previously missed. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The changes are localized to JS/TS reference emission and include targeted tests for each fixed syntax class. No functional or security issues were identified in the changed paths. No files require special attention.
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Scope as JS/TS caller scope
participant CallProcessor as CallProcessor scans
participant Registry as Function registry
participant Ingestor as Relationship ingestor
Scope->>CallProcessor: Traverse calls, assignments, returns, params, object literals
CallProcessor->>CallProcessor: Unwrap casts/parens and bubble unowned anonymous scopes
CallProcessor->>Registry: Probe named, anonymous-position, property, and pair-path candidates
Registry-->>CallProcessor: Existing callable target variants
CallProcessor->>Ingestor: Emit REFERENCES/CALLS edges to callable targets
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Scope as JS/TS caller scope
participant CallProcessor as CallProcessor scans
participant Registry as Function registry
participant Ingestor as Relationship ingestor
Scope->>CallProcessor: Traverse calls, assignments, returns, params, object literals
CallProcessor->>CallProcessor: Unwrap casts/parens and bubble unowned anonymous scopes
CallProcessor->>Registry: Probe named, anonymous-position, property, and pair-path candidates
Registry-->>CallProcessor: Existing callable target variants
CallProcessor->>Ingestor: Emit REFERENCES/CALLS edges to callable targets
Reviews (3): Last reviewed commit: "fix(js): scan assignment_pattern default..." | Re-trigger Greptile |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request enhances the JS/TS call and reference ingestion logic in call_processor.py to handle various edge cases such as TS cast-wrapped arrow bindings, curried arrows, default parameters, inline call arguments, member-assigned functions, nested pair keys, and shorthand methods. A critical issue was identified in the default parameter ingestion logic where cs.FIELD_VALUE is used instead of cs.TS_FIELD_RIGHT to retrieve the default value of a parameter in JS/TS, which would cause the ingestion to be a no-op.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Greptile SummaryThis PR expands JS/TS call graph reference handling for functions consumed through less direct syntax. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The changes are scoped to JS/TS reference recovery paths and use registry checks before emitting callable edges. Focused tests cover each syntax class described in the PR. No review findings were identified. No files require special attention.
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant CP as CallProcessor
participant AST as JS/TS AST
participant Reg as FunctionRegistry
participant Ing as Ingestor
CP->>AST: Walk caller/module scope
AST-->>CP: Calls, assignments, params, returns, object literals
CP->>CP: Unwrap TS casts/parens and bubble unowned anonymous scopes
CP->>Reg: Check function/method candidates and variants
Reg-->>CP: Registered callable targets
CP->>Ing: Emit REFERENCES/CALLS edges
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant CP as CallProcessor
participant AST as JS/TS AST
participant Reg as FunctionRegistry
participant Ing as Ingestor
CP->>AST: Walk caller/module scope
AST-->>CP: Calls, assignments, params, returns, object literals
CP->>CP: Unwrap TS casts/parens and bubble unowned anonymous scopes
CP->>Reg: Check function/method candidates and variants
Reg-->>CP: Registered callable targets
CP->>Ing: Emit REFERENCES/CALLS edges
Reviews (2): Last reviewed commit: "fix(js-ts): reference functions consumed..." | Re-trigger Greptile |
…reference their functions
|
@greptile review |
Summary
Dogfooding
cgr dead-codeagainst pmndrs/zustand surfaced six systematic JS/TS false-positive classes. All are "a function is consumed by syntax the call/reference pass did not scan," fixed with revive-only reference emission. zustand goes 32 -> 0 dead-code false positives.Fix classes (each RED -> GREEN)
test_ts_cast_wrapped_arrow_binding.py):export const createStore = ((s) => ... createStoreImpl) as CreateStorelost ALL body call/ref edges._js_ts_arrow_binding_namerequired the arrow to be the declarator's direct value; it now climbs paren/cast wrappers, matching the def pass.test_ts_curried_arrow_references.py):(config) => (set, get, api) => {...}has noreturn_statement; the expression body IS the implicit return. The returned-function pass now references function-typed bodies, including through unowned anon layers.test_ts_member_assigned_function_references.py):api.setState = (state, replace) => {...}. Two composing gaps: the assignment walk stopped at every function boundary (assignments inside anonymous curried arrows scanned by nobody), and only the position-named registration was referenced, never the property-named one (persistImpl.setState).test_ts_inline_arg_to_unresolved_callee.py): an arrow passed to a param callee (set((state) => ...)) or cast-wrapped callee (;(set as NamedSet)(...)) was consumed invisibly. Every inline function argument is now referenced from the calling scope, and calls nested purely in anonymous scopes bubble to module scope instead of nobody.test_ts_default_param_and_shorthand_method_refs.py):useStore(api, selector = identity as any)and persist's thenable{ then(x) {...}, catch(x) {...} }(method_definition nodes, which the dispatch-table scan skipped as non-pairs).test_ts_nested_pair_key_value_refs.py):configure({ onCreated: (s) => { s.setEvents({ compute: ... }) } })registers asCanvas.onCreated.compute, but the scan builtCanvas.compute; candidates now include ancestor pair keys.Also guards
_emit_callback_edgeto callable targets only (a default value can resolve a cast's TYPE name to an Interface node, which is schema-invalid as a reference target).Verification