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 trace the Angular template reference resolution and the existing handling for typed fields, constructor injection, and
newinitializers. Then I’ll add the smallest source fix, run targeted tests (without modifying repository tests), reproduce the reported scenario if practical, and review the diff before submitting. - Assistant
The relevant path is
extract_class_instance_bindings, which feeds the Angular template chain propagation. It already records constructor parameter types, explicit property types, andnew Foo()values, but its property initializer branch stops afternewand never recognizesinject(Foo). I’ll extend that branch to record the first identifier argument of aninjectcall as the bound class, matching the extractor’s existing Angular inject semantics. - Assistant
The focused extractor test suite passes (302 tests). I’m now validating the complete reported flow with a temporary standalone fixture, so the check covers parsing, module graph resolution, Angular template extraction, and dead-member propagation rather than only the helper.
- Assistant
The end-to-end temporary reproduction now reports
✓ No issues found, and the existing Angular inject integration test plus extractor tests pass. The change is limited to six lines in the class-binding extractor; it preserves existingnewbehavior, only handles identifier-basedinjectcalls, and supports options because it reads only the first argument. I’ll submit after one final diff/status check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.