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 repository structure and then reproduce the issue described.
Let me first explore the repository structure and understand what we're dealing with.
Assistant
Let me first set up the reproduction case and reproduce the issue. Let me create the reproduction files and run fallow.
Assistant
Let me create the reproduction files.
Assistant
Continue creating the reproduction files.
Assistant
Let me create the remaining files.
Assistant
Let me check if there's a built binary of fallow.
Assistant
Now let's run fallow with the reproduction case.
Assistant
I've reproduced the issue. Now let me explore the codebase to understand how the Angular plugin works and find where the fix needs to be applied.
Assistant
Let me navigate back to the fallow directory.
Assistant
Let me search for where Angular-related code lives and where
injectis handled.Assistant
Let me look at the Angular plugin and the integration test for Angular template members.
Assistant
Let me search for where Angular template references are resolved and where component properties are linked to service types.
Assistant
Let me look at
unused_members.rswhich is the main file for detecting unused class members.Assistant
Let me search for "inject" and "template" in the unused_members.rs file and also look for angular-related member detection.
Assistant
Let me look at the context around line 1433 and the surrounding code.
Assistant
Let me search for
instance_bindingsto understand how it's populated.Assistant
Let me look at the
extract_class_instance_bindingsfunction.Assistant
Let me find the
extract_class_instance_bindingsfunction.Assistant
Let me look at the
extract_class_instance_bindingsfunction.Assistant
Now I can see the issue. In
extract_class_instance_bindings, there are two paths for extracting bindings from aPropertyDefinition:- Explicit type annotation
NewExpressionvalue
But there's no handling for when the property value is a
CallExpressionlikeinject(ExampleService). Let me verify this is indeed the missing case and look for any existinginjecthandling.Assistant
Let me look at the visit_impl.rs to understand how inject is currently
Assistant
Let me look at the test files to understand what cases are currently covered.
Assistant
Let me find and look at this fixture.
Assistant
Let me look at the test fixture files
Assistant
Let me look at the angular template members integration test and fixture.
Assistant
Let me look at the angular-template-inherited-members fixture.
Assistant
Let me look at the test for inject field mapping and how the visitor handles it
Assistant
Let me look at how
instance_bindingsis extracted invisit_impl.rs:Assistant
Let me look at how the named export case handles class heritage:
Assistant
Let me look at where the binding target mapping happens for inject fields in the visitor:
Assistant
Let me find where
extract_angular_inject_targetis called:Assistant
Let me look at where
extract_angular_inject_targetis used:Assistant
Let me check how
record_typed_bindingworks and whether it connects toinstance_bindings:Assistant
Let me look at the
propagate_accesses_through_typed_instance_bindingsfunction:Assistant
Let me search for
build_typed_instance_binding_targets:Assistant
Let me look at
build_typed_instance_binding_targets:Assistant
Now I understand the issue completely. The
extract_class_instance_bindingsfunction inhelpers.rsdoesn't handleCallExpressionvalues likeinject(ExampleService). Let me implement the fix.Assistant
Let me look at the key section of the code I need to modify:
Assistant
Let me check the imports of helpers.rs:
Assistant
Now I have a clear understanding. Let me implement the fix. I need to add handling for
CallExpressionvalues inextract_class_instance_bindingsto handleinject()calls.Assistant
I see the bash
!history expansion issue caused the!is_builtin_constructorcheck to be dropped. Let me fix this and also verify the edit.Assistant
I need to restore the
!is_builtin_constructorcheck that was accidentally removed. Let me fix this:Assistant
Bash history expansion is eating the
!. Let me disable it and fix:Assistant
Let me use the replace command to fix the missing check:
Assistant
The code looks correct now. Let me verify the full function and then build and test:
Assistant
Let me check the full function to make sure the braces are balanced:
Assistant
Something looks off. Let me check git diff to see the exact changes:
Assistant
I see the problem! The edit accidentally removed the
_ => {}catch-all arm. Let me fix this:Assistant
Let me look at the original code again and carefully apply only the needed change:
Assistant
Now let me apply the edit correctly this time:
Assistant
Let me verify the diff is correct:
Assistant
The diff looks clean. Now let me build and test:
Assistant
Build succeeded. Now let me test the reproduction case:
Assistant
The issue still reproduces. Let me investigate further. Let me check if the template is associated with the component and if the member accesses are being detected:
Assistant
Let me look at
template_usage.rs:Assistant
Let me search for where
collect_unresolved_refs_and_accessesis called:Assistant
Let me look at the Angular SFC template handling:
Assistant
Let me look at how the template refs are used in
visit_impl.rs:Assistant
Let me search for where external Angular template files are loaded:
Assistant
Let me search for where
has_angular_component_template_urlis set totrue:Assistant
Let me look at the context around line 3038:
Assistant
Let me search for where the external template file is processed
Assistant
Let me look at
html.rsto see how external template files are processed:Assistant
Let me run the existing tests to make sure my change doesn't break anything:
Assistant
Let me run the inject-related tests:
Assistant
Let me verify the binary is up to date and test with an inline template version:
Assistant
Let me try an inline template version to see if the issue is specific to external templates:
Assistant
Let me investigate whether the external template is being properly processed as an HTML file:
Assistant
Let me look at the
extract.rsfile to understand how HTML files are processed:Assistant
Let me look at
parse.rsin the extract crate:Assistant
Let me check
is_html_fileto make sure.htmlfiles are processed:Assistant
Let me look at the
is_html_filefunction and the HTML parsing:Assistant
Let me look at the HTML parsing function:
Assistant
Let me check how
class_heritage_by_fileis built:Assistant
Let me look at the context around line 1304:
Assistant
Let me look at
record_local_class_export:Assistant
Let me look at
record_local_class_export:Assistant
Let me look at
record_exported_instance_bindings:Assistant
Let me search for where
class_heritageis built fromlocal_class_exports:Assistant
Let me find where local_class_exports is consumed:
Assistant
Let me look at
enrich_local_class_exports:Assistant
Let me search for existing tests for
extract_class_instance_bindingsto understand the test patterns:Assistant
Let me look at the test around line 3245:
Assistant
Let me look at the
parsetest helper function:Assistant
Let me look at the test module imports and parse function:
Assistant
Let me write a small test to verify the
instance_bindingsextraction works:Assistant
Let me look at how named export declarations handle class heritage:
Assistant
Let me look at
visit_export_named_declaration:Assistant
Let me look at
extract_declaration_exports:Assistant
Let me search for
extract_declaration_exports:Assistant
Let me look at
extract_declaration_exportsin declarations.rs:Assistant
Let me look at
build_local_to_export_keys:Assistant
Let me look at
build_local_to_export_keys:Assistant
Let me run more tests to make sure nothing is broken:
Assistant
All extract tests pass. Let me run the core integration tests related to our fix:
Assistant
Let me verify the binary is fresh and rebuild if needed:
Assistant
Let me check the
Argumenttype to see if my pattern matching is correct:Assistant
Let me create a specific test to verify my change works at the unit level:
Assistant
Let me search for tests that verify
instance_bindingswithnewexpressions:Assistant
Let me look at the test that checks instance_bindings:
Assistant
Let me add temporary debug output to check if my code is being executed:
Assistant
Let me verify the
Argumenttype definition:Assistant
Let me add a unit test to verify the extraction works:
Assistant
Let me look at the end of the test module:
Assistant
Let me try with npm install:
Assistant
Let me check what fallow actually analyzes. Let me look for debug/verbose output options:
Assistant
Let me look at
normalize_asset_url:Assistant
Let me look at
normalize_asset_url:Assistant
Let me verify the external template test still passes:
Assistant
Let me verify that the typed version works as expected:
Assistant
Now let me revert to the untyped version:
Assistant
It works now! Let me verify the binary path:
Assistant
Let me verify the files in the repro directory:
Assistant
Let me run the reproduction one more time to confirm it works consistently:
Assistant
The fix works. Let me now run all the tests to make sure nothing is broken, and also verify edge cases:
Assistant
Let me verify that genuinely unused members are still detected by testing with a class member that's not used:
Assistant
The fix works correctly:
onValueChangeis properly credited as used, whileunusedMethodis correctly flagged as unused. Let me restore the original reproduction and do a final verification:Assistant
The issue is resolved. Let me run the full test suite:
Assistant
All tests pass. Let me also run the extract crate tests one more time:
Assistant
All tests pass. Let me review the final change:
Assistant
Now let me go through the checklist:
Checklist
-
If an error was reported in the issue description, I have successfully reproduced it.
- ✅ Yes, I reproduced the exact issue with the provided reproduction case. The
onValueChangemethod was reported as unused when using untyped .
- ✅ Yes, I reproduced the exact issue with the provided reproduction case. The
-
Assistant
The fix is complete and all tests pass. Let me submit the changes.
Assistant
The change is clean. Let me submit it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.