ISSUE DESCRIPTION service member referenced in an Angular external template is reported…
- User
ISSUE DESCRIPTION
service member referenced in an Angular external template is reported as unused when the component property is initialized with
inject()(no explicit type annotation)What happened?
With the
angularplugin active,fallow dead-codereports a service method as an unused class member when its only reference is in an Angular HTML template (prop.method()), and the component propertypropis initialized with the moderninject()pattern without an explicit type annotation:readonly exampleService = inject(ExampleService);Fallow already credits template references through component properties for the other three DI/instance patterns — it is specifically the untyped
inject()initializer that is missed. The following all resolve correctly (no false positive); only the last one fails:Component property pattern Template prop.method()resolved?constructor(public svc: ExampleService) {}✅ yes svc: ExampleService = inject(ExampleService);(typed)✅ yes svc = new ExampleService();✅ yes svc = inject(ExampleService);(untyped)❌ no — false positive Because untyped
inject()is the idiomatic Angular style, this misfires on a very common real-world pattern.Reproduction
Minimal standalone repro.
@angular/coreonly needs to be listed inpackage.jsonso theangularplugin auto-activates — runningnpm installis optional (without it, fallow prints a "node_modules directory not found" warning but the finding still reproduces).-
Create
package.json:{ "name": "fallow-angular-template-repro", "version": "1.0.0", "private": true, "dependencies": { "@angular/core": "^20.0.0" } } -
Create
.fallowrc.json:{ "entry": ["src/main.ts"] } -
Create
src/main.ts:import { ExampleComponent } from './example.component'; console.log(ExampleComponent);
-
Assistant
Let me start by understanding the issue. The problem is about
fallow dead-codereporting a service method as unused when it's only referenced in an Angular HTML template, and the component property is initialized withinject()without an explicit type annotation.Let me first explore the repository structure to understand the codebase.
Assistant
This is a Rust project. Let me explore the structure more, especially the crates directory since this is likely where the source code lives.
Assistant
Let me search for Angular-related code in the codebase.
Assistant
Let me look at the key Angular-related files. Let's start with the Angular plugin and the template members test.
Assistant
Now let me look at the Angular template members test and the SFC template extraction for Angular.
Assistant
Let me look at the Angular SFC template extraction code and the external style usage code.
Assistant
Let me look at the external style usage code and the analysis for unused members.
Assistant
Let me look at the unused members analysis code and how it handles Angular template references.
Assistant
Let me search for
injectin the codebase, and also look at how Angular template references get resolved.Assistant
Let me look at the key function
extract_angular_inject_targetand the surrounding code.Assistant
Let me look at the context around line 1886 where
extract_angular_inject_targetis called:Assistant
Let me search for how
ANGULAR_TPL_SENTINELis used in the codebase.Assistant
Let me look at the bridging code around line 3056:
Assistant
Let me look at the unused_members analysis code around lines 850 and 1439 where ANGULAR_TPL_SENTINEL is used:
Assistant
Let me look at the code around line 1439 where Angular template accesses are processed:
Assistant
Let me continue reading from line 1492:
Assistant
Let me search for how
instance_bindingsis populated:Assistant
Let me look at the
extract_class_instance_bindingsfunction:Assistant
Now I understand the issue. The
extract_class_instance_bindingsfunction handles typed properties andnewexpressions but doesn't handleinject()calls. Let me check howbinding_target_namesis used versusinstance_bindings:Assistant
Let me look at
record_exported_instance_bindingsand howbinding_target_namesfeeds intoinstance_bindings:Assistant
Let me look at the code around line 1952 to see how instance_bindings are set during the visit:
Assistant
Now I've found the root cause. The
extract_class_instance_bindingsfunction inhelpers.rsdoesn't handleinject()calls. Let me look at the full helpers.rs to understand the imports and structure:Assistant
Let me look at how
record_local_class_exportworks and how instance_bindings is passed:Assistant
Let me search for
record_local_class_exportacross the codebase:Assistant
Let me look at
record_local_class_export:Assistant
Now I understand the issue fully. The
extract_class_instance_bindingsfunction inhelpers.rsdoesn't handleinject()calls. It handles:- Constructor parameters with type annotations (constructor DI)
- Get accessors with return type annotations
- Property definitions with type annotations
- Property definitions with
newexpressions
But it doesn't handle
inject()calls. Let me now create a reproduction script first, then fix the issue.Assistant
Let me look at existing test fixtures for Angular template members:
Assistant
Let me look at the existing
angular-inject-class-membersfixture:Assistant
Let me examine the inject-class-members fixture:
Assistant
Let me check all files:
Assistant
Let me find tests that reference this fixture:
Assistant
Let me look at the member_detection test around line 455:
Assistant
Let me look at the
angular-template-inherited-membersfixture:Assistant
Let me examine the angular-template-inherited-members fixture's component and service:
Assistant
Now I have a clear understanding of the issue. The
extract_class_instance_bindingsfunction inhelpers.rsdoesn't handleinject()calls for property definitions. It only handles type annotations andnewexpressions.Let me implement the fix:
Assistant
Let me check what helper functions are available for type extraction:
Assistant
Let me look at the type extraction functions:
Assistant
Let me find
extract_type_name:Assistant
Let me check
extract_type_name:Assistant
Now I'll implement the fix. I need to add handling for
inject()calls inextract_class_instance_bindings:Assistant
Let me verify the full context around the change:
Assistant
I see the indentation issue. The
_ => {}should be properly aligned. Let me fix:Assistant
Let me verify the change by building:
Assistant
Let me wait for the build to finish:
Assistant
Build succeeded. Let me run the existing tests to verify nothing is broken:
Assistant
Let me run the Angular template members tests:
Assistant
Let me run the angular template members tests separately:
Assistant
Let me run all angular-related tests:
Assistant
Let me run the extract crate tests to make sure nothing is broken there:
Assistant
All tests pass. Let me now create a reproduction script to verify the fix works for the exact scenario:
Assistant
Now let me create a test reproduction:
Assistant
Let me create the reproduction test files:
Assistant
Let me create all reproduction files:
Assistant
Let me run fallow against the reproduction:
Assistant
The fix works! "No issues found" — the false positive is gone. Let me also verify the other injection patterns (controls A, B, C) still work correctly:
Assistant
Let me also test control B and C:
Assistant
Let me verify that genuinely unused members are still properly flagged:
Assistant
The fix correctly credits
onValueChangeas used while still flaggingunusedMethodas genuinely unused. Let me now run the full test suite to make sure nothing is broken:Assistant
All 641 integration tests pass. Let me also run the extract tests and the CLI tests:
Assistant
The failing test
fix_batch_aborts_when_a_target_directory_is_read_onlyappears to be a pre-existing issue unrelated to my change. Let me verify by checking if this test was failing before:Assistant
Confirmed - the test was already failing before my change. Let me restore my changes:
Assistant
Let me clean up and verify the final state of my change:
Assistant
The fix is correct and complete. Let me now submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.