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
Let me check that
class_heritageis cached, and look at existing tests: - Assistant
Now update
extract_class_instance_bindingsand add the shared inject-call helper: - Assistant
Still used. Now update
declarations.rs: - Assistant
Now bump
CACHE_VERSIONsince cachedclass_heritage.instance_bindingscontent changes: - Assistant
Now build the extract crate to check compilation:
- Assistant
Now add tests. First check the
parsehelper in visitor tests: - Assistant
Now add unit tests after
typed_getter_records_instance_binding: - Assistant
Now run the extract unit tests:
- Assistant
All pass. Now create the integration fixture mirroring the issue's repro:
- Assistant
Now add the integration test:
- Assistant
All pass. Let me verify end-to-end with the CLI against the repro fixture:
- Assistant
The false positive is gone — only the genuine control finding remains. Now run the full workspace checks:
- Assistant
The shell is temporarily failing (likely while the background suite runs). I'll use the file tools instead:
- Assistant
Bash/Glob/Grep are all transiently failing; Read/Edit still work. Let me find the Angular metadata entry by reading pages:
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.