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:tsreadonly 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:json{ "name": "fallow-angular-template-repro", "version": "1.0.0", "private": true, "dependencies": { "@angular/core": "^20.0.0" } } -
Create
.fallowrc.json:json
-
- Assistant
I'll start by exploring the repository structure and locating the Angular plugin code that resolves template references through component properties.
- Assistant
Next I’ll search the codebase for Angular template / inject() handling.
- Assistant
rg is not available, let me use grep instead.
- Assistant
I'll inspect the Angular plugin and related tests around template member resolution and
inject(). - Assistant
Looking at the angular template members integration test and inject-related logic next.
- Assistant
Inspecting template reference resolution and how property types are inferred around the angular-related code.
- Assistant
The binding comes from
instance_bindingson class heritage — I'll find where those are populated. - Assistant
Reading the
extract_class_instance_bindingsimplementation. - Assistant
Confirmed:
extract_class_instance_bindingshandles type annotations andnewbut not untypedinject(). Checking for existinginjecthandling and how call expression types are extracted. - Assistant
There's already inject handling elsewhere — checking
visit_impl.rsand the existing fixture. - Assistant
I'll check how
extract_angular_inject_targetis used and how template member accesses are recorded. - Assistant
Checking how inject bindings are currently recorded in the visitor.
- Assistant
I'll inspect where instance_bindings are recorded on class finish and whether we can plug inject targets in there.
- Assistant
Checking local class instance-binding extraction and call-sites.
- Assistant
I'll check CSV utility patterns and how docs read around inject extraction, then implement the fix.
- Assistant
Looking at the angular template fixture:
- Assistant
Checking external template chain access extraction and
type_name_root. - Assistant
Implementing inject() extraction in
extract_class_instance_bindingsand adding unit tests. - Assistant
I need to add the CallExpression case after NewExpression. Also need CallExpression in imports - let me check the imports.
- Assistant
Adding the helper function next to the related Angular extraction helpers.
- Assistant
I'll add extract_inject_initializer_type after extract_angular_signal_query.
- Assistant
I'll add the helper function after extract_angular_signal_query.
- Assistant
Per instructions I won't add permanent tests. I'll reproduce the issue with a temporary fixture and verify the fix builds.
- Assistant
Building the CLI — this may take a while.
- Assistant
Let me check the package names.
- Assistant
Let me build fallow-cli and fallow-extract.
- Assistant
Build succeeded. Running the reproduction against the fixed binary.
- Assistant
Need figure out how to run with a given directory.
- Assistant
Let me check how to set the project root.
- Assistant
Looking at more help for directory option
- Assistant
The main case is fixed. Verifying typed inject and type-argument variants next.
- Assistant
Verifying nullable union type annotations and cleaning up the change for review.
- Assistant
The fix looks complete. I'll clean up temp fixtures and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.