service member referenced in an Angular external template is reported as unused when the…
- User
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
Now bump the cache version since emitted
class_heritage.instance_bindingschange: - Assistant
Now add a visitor test next to the existing
typed_getter_records_instance_bindingtest: - Assistant
Now create the integration fixture reproducing the issue exactly:
- Assistant
All Angular tests pass, including the new one. Now run the wider suite plus clippy and fmt:
- Assistant
The repro now reports
✓ No issues found. Run the rest of the workspace tests to be safe: - Assistant
While tests run, update the detection docs to reflect that
instance_bindingsnow covers untypedinject()fields: - Assistant
The docs edit was blocked (sensitive file) — I'll leave that to you and note the suggested wording below. Waiting on the workspace test run:
- Assistant
The full workspace test run is still going in the background — I'll report as soon as it completes.
- Assistant
No failures so far in the interim output. I'll summarize once the run finishes.
- Assistant
The background test run buffers its output through the final pipe, so nothing shows until it exits. It will re-invoke me on completion — standing by.
- Assistant
Waiting for the workspace test suite to finish — I'll post the final summary when it completes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.