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: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
I’ll trace the Angular template-to-property type resolution, add the missing
inject()inference case, and cover it with a regression test alongside the existing DI patterns. - Assistant
The template scanner already captures
exampleService.onValueChange. The missing link is narrower: exported class metadata records typed fields andnewfields, but it does not copy the already-supported Angularinject()target into the component’s public instance bindings. I’m updating that metadata path while preserving the existing check thatinjectactually comes from@angular/core. - Assistant
The implementation and both regression layers are in place: an extraction test checks the inferred public binding, and an end-to-end fixture checks the external HTML template credits the service method while a genuinely unused method remains reportable. The targeted Rust tests are compiling now.
- Assistant
The broader extraction suite and all member-detection integration tests pass. One repository-specific requirement surfaced during final review: extraction-semantic changes must invalidate the incremental parse cache, since old cached component metadata would retain the false positive. I’m adding that version bump before the final verification.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.