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 start by exploring the repository structure and locating the Angular plugin code that resolves template references through component properties.
- Assistant
Next I'll search for Angular template and
inject()handling in the codebase. - Assistant
rg is not available, let me use grep.
- Assistant
I'll inspect the Angular plugin and its template-member tests next.
- Assistant
The Angular plugin may not own member resolution; I'll search unused-members and extract for how component properties bind to types.
- Assistant
I'll read the typed-instance chain resolution and Angular integration tests.
- Assistant
I'll locate
build_typed_instance_binding_targetsand how inject initializers are typed. - Assistant
Let me read the build_typed_instance_binding_targets function fully.
- Assistant
I'll track where
instance_bindingsare collected during extraction. - Assistant
I'll open
extract_class_instance_bindings, which should be where inject typing is decided. - Assistant
Found the gap: untyped
inject()initializers aren't mapped. I'll check existing tests and any inject handling nearby. - Assistant
There's already Angular inject mapping nearby — I'll read that block and the fact fixture.
- Assistant
There's an angular-inject fixture. Let me see how inject is currently handled for class members and template usage.
- Assistant
I'll inspect Angular inject target extraction and how template member accesses are recorded.
- Assistant
Let me find how inject creates binding_target_names and how templates use instance bindings.
- Assistant
I'll read the section that credits Angular template accesses onto class members.
- Assistant
Let me continue reading this section to see how template chain accesses are resolved.
- Assistant
I'll inspect how inject bindings are recorded during visitation.
- Assistant
Looking at the instance_bindings tests more carefully:
- Assistant
I'll check helpers module structure and imports so I can add inject initializer support cleanly.
- Assistant
I'll implement the fix by extending
extract_class_instance_bindingsto handle inject initializers. I should useextract_type_reference_namefor type args. - Assistant
I'll inspect where class instance bindings are recorded so inject can be wired in correctly.
- Assistant
I'll implement the inject initializer binding fix and then reproduce the reported false positive.
- Assistant
I need to make sure the file is scrolled to the target before applying the edit.
- Assistant
Now I'll apply the edit.
- Assistant
I'll align
extract_angular_inject_targetwith the shared helper after the import check. - Assistant
Need to open the other file.
- Assistant
I'll refactor this to use the shared helper.
- Assistant
That last refactor was broken — I'll clean up the inject target helpers properly.
- Assistant
I'll split the helper into call- and expression-level extractors.
- Assistant
I need to add CallExpression to imports and split the function.
- Assistant
Need to go to line 1
- Assistant
Actually CallExpression might not need to be imported if we use oxc_ast::ast::CallExpression in the signature, or we can match without naming CallExpression in the type.extract_inject_call_target alre...
- Assistant
Now update the function to split into from_call and expression wrapper.
- Assistant
I'll replace the function with the split version.
- Assistant
Aliased
injectmust keep working, so I'll stop re-checking the callee name in the shared call helper. - Assistant
The expression path must still require the callee to be named
inject. - Assistant
I'll build the extract crate and recreate the minimal repro.
- Assistant
No prebuilt binary is available, so I'll compile the project next.
- Assistant
Build succeeded. Now I'll create the repro fixture and run it.
- Assistant
Need to check fallow CLI usage.
- Assistant
Looking at fixtures for how entry and config root are set.
- Assistant
Use --root
- Assistant
Repro is clean. Next I'll verify edge cases: unused methods, typed inject, and
inject<Type>(). - Assistant
Edge cases look good. I'll run the related unit and integration tests next.
- Assistant
All related tests passed. I'll also run the unused_members unit tests for safety.
- Assistant
I'll review the final diff and clean up the temporary repro.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.