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
This is a Rust codebase. Let's look at the angular.rs plugin file.
Assistant
Now let's find where "bound_targets" (component property -> service type) is built — likely in angular.rs.
Assistant
Now let's find where
self_accessed_membersis bridged using type bindings (constructor injection,newexpressions, typed inject).Assistant
Found it. Let's look at
extract_class_instance_bindingsin helpers.rs.Assistant
Now let's edit the PropertyDefinition branch to also handle
inject(Service)calls.Assistant
Let's look at line 338 context for a similar pattern that might already handle inject with identifier arg.
Assistant
Now let's add the inject() call handling after the NewExpression check.
Assistant
The edit tool syntax needs
edit LINE_RANGEthen heredoc separately. Let me use correct syntax.Assistant
There's a stray extra
}at line 696. Let me fix that.Assistant
Now let's build to check for compile errors.
Assistant
Compiles fine. Now let's check there is a "get()" branch for readonly properties potentially - also check
readonlymodifier doesn't matter for parsing (property withreadonlykeyword should still parse same). Let's create a repro to test end-to-end using the CLI.Assistant
The fix works. Now let's verify the other control cases still work, and existing tests pass.
Assistant
All 1681 tests pass. Let's also run core crate tests related to unused_members and angular.
Assistant
All 641 tests pass. Let's also check the existing fixture
angular-inject-class-membersto see if there's a related test already, and check test files that specifically testextract_class_instance_bindings.Assistant
All angular-related tests pass. Let's also check
angular_template_memberstest file to see the fixture used, to ensure the untyped inject pattern is possibly already covered or verify with the fixture for consistency.Assistant
The diff is minimal and clean. Let's run full test suites once more to be safe.
Assistant
All tests pass. Now let's review the checklist.
Assistant
Checklist review:
-
Reproduced the error: Yes — I built a minimal repro matching the issue's steps exactly (package.json, .fallowrc.json, main.ts, example.service.ts, example.component.ts with untyped
inject(ExampleService), example.component.html) and ranfallow dead-code, confirming the false-positiveExampleService.onValueChangeunused-class-member finding before my fix. -
Confirmed the fix resolves the error: Yes — after adding the
inject()call-expression handling inextract_class_instance_bindings(in ), rerunning the exact same repro produces , confirming the template reference is now correctly credited to .
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.