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 let me look at the two call sites of
extract_class_instance_bindingsin visit_impl.rs and the one in declarations.rs: - Assistant
Now let me check the integration test and fixture layout, plus the cache version:
- Assistant
Now I'll implement. First,
helpers.rs— add the sharedinject()target extractor and extendextract_class_instance_bindings: - Assistant
Now the untyped
inject()branch in thePropertyDefinitionarm: - Assistant
Now bump
CACHE_VERSIONsince cachedinstance_bindingsfrom pre-fix runs would lack the new bindings: - Assistant
Now build to check for errors:
- Assistant
Builds clean. Now add unit tests in the extract visitor tests:
- Assistant
Unit tests pass. Now extend the integration fixture with the untyped-
inject()repro: - Assistant
Now update the integration test to assert the new case:
- Assistant
Clippy is clean; just a formatting nit. Fix and re-check:
- Assistant
Now run the full workspace test suite:
- Assistant
The rules file is protected — I'll leave the doc note to the summary. Checking on the workspace test run:
- Assistant
The shell remains unavailable; I'll report the workspace-wide test results as soon as the background run (
b1kvbgl1g) completes and re-invokes me.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.