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 constructor parameters, typed fields, and
newinitializers. Then I’ll add the narrowest source fix, run the relevant test suite (without modifying tests), and verify the diff and edge cases before submitting. - Assistant
rgis unavailable in this environment, so I’ll usegrep/findinstead and continue locating the plugin implementation. - Assistant
The missed case is in
extract_class_instance_bindings: property bindings currently record an explicit type annotation ornew Class(), but not a call initializer. I’ll extend only this extraction path to recognize directinject(Service)initializers whose first argument is a class identifier, preserving the existing private-member and built-in filtering behavior. This lets the already-existing Angular template propagation use the inferred service binding. - Assistant
The standalone reproduction now reports
✓ No issues found, confirming the false positive is resolved. The existing extractor and Angular integration tests also pass; I’ll run the broader affected integration target and inspect formatting/status for unintended changes. - Assistant
Verification is complete:
- Reproduction: confirmed the original scenario and then confirmed the patched binary returns no issues.
- Existing affected tests: all 641
fallow-coreintegration tests passed. - Extractor tests: all 1,681
fallow-extractlibrary tests passed. - Formatting/diff checks:
cargo fmt --checkandgit diff --checkpassed; only the intended helper file changed. - Edge cases considered: explicit types and
newremain unchanged; only directinject()calls with an identifier service argument are inferred, and built-in constructor names remain excluded.
I’ll now submit the single-file fix.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.