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
Let me start by understanding the issue:
-
The issue is about
fallow dead-codereporting a service method as unused when:- The method is only referenced in an Angular HTML template
- The component property is initialized with
inject()without explicit type annotation
-
The fix should be in the code that resolves component property → service type binding. It currently handles:
- Constructor injection (
constructor(public svc: ExampleService) {}) - Typed
inject()(svc: ExampleService = inject(ExampleService)) newinitializer (svc = new ExampleService())- But NOT untyped
inject()(svc = inject(ExampleService))
- Constructor injection (
Let me first explore the repository structure and understand how the codebase is organized.
-
Assistant
This is a Rust project (Fallow). Let me explore the crates directory to understand the structure better.
Assistant
Let me search for Angular-related code and the
injecthandling:Assistant
Let me look at the Angular plugin and the template usage extraction code:
Assistant
Let me look at the template usage extraction code:
Assistant
Let me search for where template member accesses are resolved against component properties:
Assistant
Let me look at the key files - the Angular SFC template handling and the visitor that resolves bound member accesses:
Assistant
Now let me look at the visitor's
resolve_bound_member_accessesand how component property types are resolved:Assistant
Let me look at the integration test for angular template members to understand what's supposed to happen:
Assistant
Let me look at the fixture for the angular template members test:
Assistant
Let me look at the inherited members fixture to see how the data component is set up (to understand what the typed inject pattern looks like):
Assistant
Let me look at the files in this fixture:
Assistant
Now let me look at how
instance_bindingsare collected in the visitor, specifically for constructor parameters andinject()calls:Assistant
Let me look at the key areas in the visitor code - the
extract_angular_inject_targetandextract_class_instance_bindings:Assistant
Let me look at lines around 1637 and the helper function:
Assistant
Now let me look at the
extract_class_instance_bindingshelper:Assistant
Let me look at the
extract_class_instance_bindingsfunction in helpers.rs:Assistant
Let me look at lines around 1880-1970 in visit_impl.rs to see the other inject handling:
Assistant
Now I understand the issue! Let me look at how
inject()is detected elsewhere to understand the pattern better:Assistant
Now let me understand the exact code change needed. The issue is in
extract_class_instance_bindingsin helpers.rs. Let me check what imports are neededAssistant
Let me verify the oxc AST structure for
Argument:Assistant
Let me check how
ArgumentandCallExpressionare used in the codebase:Assistant
Now I understand the issue fully. Let me look at the exact code I need to modify:
Assistant
Let me check where
type_name_rootis defined, sinceextract_angular_inject_targetuses it:Assistant
Now I have a clear understanding of the issue. Let me implement the fix. The problem is in
extract_class_instance_bindingsincrates/extract/src/visitor/helpers.rs- it doesn't handleinject()calls for property initializers.Assistant
There seems to be a problem with my edit - it looks mangled. Let me see the full context:
Assistant
The edit went wrong. Let me restore the file and redo it:
Assistant
Let me verify the file is restored:
Assistant
Good, now the file is restored. Let me add the inject check properly. I need to insert it after the NewExpression check block:
Assistant
There's a duplicate closing brace. Let me fix it:
Assistant
The code looks correct now. Let me verify the complete PropertyDefinition match arm:
Assistant
Good, the code looks correct. Let me build the project to verify it compiles:
Assistant
The project compiles. Now let me create the reproduction case from the issue description and test it:
Assistant
Now let me create the test files:
Assistant
Let me look at the actual config format from the existing test fixtures:
Assistant
Let me look at the fallow config schema and the integration test common setup to understand the correct config format:
Assistant
Let me look at how the tests are configured:
Assistant
Let me run the existing angular template members test to make sure it still passes:
Assistant
Let me find the exact test name:
Assistant
Let me run the specific relevant tests:
Assistant
Let me try running the tests differently:
Assistant
The existing tests still pass. Let me also run the inject-specific test:
Assistant
Let me look at the existing member_detection test to understand how the inject test is set up:
Assistant
Let me look at this test:
Assistant
Let me look at the fixture for
angular-inject-class-membersto understand what it tests:Assistant
Now I understand the difference. The existing test uses
this.inner.aaa(which goes throughbinding_target_names), but the issue is about external templates where properties are referenced withoutthis.. Let me create a reproduction test case:Assistant
Now let me run fallow on the reproduction case:
Assistant
The fix works! The false positive is gone. Let me now also verify that the issue existed before the fix by temporarily reverting and running:
Assistant
Now let me run the reproduction with the original (unfixed) code:
Assistant
Let me look more carefully at how template member accesses flow through the system. Let me find
resolve_bound_member_accesses:Assistant
Let me go back to the project root:
Assistant
Let me look at how external template member accesses are handled. Let me check
parse.rs:Assistant
Let me look at how
unused_members.rsresolves template member accesses:Assistant
Let me search for
ANGULAR_TPL_SENTINELto understand how template member accesses flow:Assistant
Let me look at the key section in unused_members.rs:
Assistant
Let me restore my fix and investigate more:
Assistant
Let me look at how external templates are processed - specifically the HTML module:
Assistant
Let me carefully re-test without the fix by explicitly reverting the change and rebuilding:
Assistant
Let me properly test without the fix by reverting, building, and testing:
Assistant
Good. Now let me run the repro test again, but this time let me add some debugging to see what's happening. Actually, let me just run it and see:
Assistant
Let me check if the Angular plugin is being activated. Let me add
@angular/coreto node_modules or check if the plugin activates:Assistant
Let me check how plugin detection works:
Assistant
Let me look at the plugin registry:
Assistant
Let me find the plugin registry:
Assistant
Let me look at how plugins are detected:
Assistant
Let me search for the
define_pluginmacro to understand how plugin detection works:Assistant
Let me look at the define_plugin macro:
Assistant
Let me search for how plugins are actually detected/activated:
Assistant
Let me look at the registry module:
Assistant
Let me find how plugins check if they're enabled:
Assistant
Let me get more verbose output from fallow:
Assistant
Let me look at how HTML templates are connected to components. Let me check how the template URL is processed:
Assistant
Let me look at how the templateUrl is processed in the visitor:
Assistant
Let me look at that section:
Assistant
Let me check if the Angular plugin is being activated. Let me examine the package.json format more carefully:
Assistant
Let me create a more thorough reproduction. Maybe the issue requires the fixture to be within the project's test framework. Let me look at how the existing test fixtures are set up:
Assistant
Let me check how
is_enabled_with_depsis implemented for the Angular plugin:Assistant
Let me look at the default
is_enabled_with_deps:Assistant
Let me create a test fixture directly in the tests directory to test this properly:
Assistant
Let me create the fixture files:
Assistant
Now let me run fallow against this fixture:
Assistant
Let me use the correct binary name:
Assistant
Wait, let me check the current state of my fix:
Assistant
My fix was reverted! Let me check the current state of the file:
Assistant
Let me run fallow only on the specific fixture directory, without scanning the entire tests directory:
Assistant
Let me check how fallow discovers workspaces. Maybe it's picking up the root package.json:
Assistant
Let me check the root .fallowrc.json:
Assistant
Let me take a different approach. Let me write a Rust integration test that directly tests the scenario:
Assistant
Let me create a proper test fixture and integration test. First, let me create the fixture:
Assistant
Now let me add a test to member_detection.rs. Let me first check the end of the file:
Assistant
Let me look at the end of the file:
Assistant
Let me add a test for the external template with untyped inject:
Assistant
Now let me run this test first WITHOUT my fix to confirm the issue:
Assistant
I've reproduced the bug! The test fails because
ExampleService.onValueChangeis reported as unused. Now let me apply my fix:Assistant
Now let me apply the fix:
Assistant
There's a duplicate closing brace again. Let me fix it:
Assistant
Good. Now let me run the test with my fix applied:
Assistant
My fix resolves the issue. Now let me run all the related tests to make sure nothing is broken:
Assistant
Let me try a different test filter:
Assistant
Let me also run the existing angular_inject test:
Assistant
Let me run the full integration test suite to make sure nothing is broken:
Assistant
All 642 tests pass. Let me also run the extract crate tests:
Assistant
All tests pass. Let me also run the core unit tests:
Assistant
All tests pass. Now let me clean up - remove the test and fixture I added (as the instructions say not to modify tests):
Assistant
Now let me also clean up the fixture I created:
Assistant
Let me verify the final state of my changes:
Assistant
Let me run the full test suite once more to confirm everything passes:
Assistant
Let me also verify the build:
Assistant
Everything looks good. Let me now summarize and submit.
Checklist
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ Yes. I created a test fixture with an untyped
inject(ExampleService)property in an Angular component with an external template. Without the fix,ExampleService.onValueChangewas incorrectly reported as an unused class member. With the fix, the false positive is resolved. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ Yes. The test passes with my fix applied.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.