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:readonly 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:{ "name": "fallow-angular-template-repro", "version": "1.0.0", "private": true, "dependencies": { "@angular/core": "^20.0.0" } } -
Create
.fallowrc.json:{ "entry": ["src/main.ts"] } -
Create
src/main.ts:import { ExampleComponent } from './example.component'; console.log(ExampleComponent);
-
Assistant
Found relevant area around line 1860-1960 and
extract_class_instance_bindings. Let's inspect.Assistant
CallExpression is already used in helpers.rs via oxc_ast::ast::CallExpression fully qualified. Now let's edit the function.
Assistant
Now editing lines 680-686:
Assistant
Now add the
extract_inject_call_targethelper function. Let's add it right afterextract_class_instance_bindings(after line 697).Assistant
Now let's try building.
Assistant
Builds fine. Now let's create the reproduction fixture and test with the CLI.
Assistant
Now let's create a temporary reproduction fixture to test the actual issue with an external HTML template.
Assistant
No issues found now. Let's confirm it was reproducing before the fix by checking with git stash.
Assistant
Ah, there's a cache! That's why unfixed run showed no issue — it used cached results from the fixed build. Let's remove cache and retest.
Assistant
Confirmed reproduction with unfixed code. Now restore fix and rebuild, then rerun with fresh cache.
Assistant
Fix confirmed working. Now let's test the control cases still work and run the existing test suite.
Assistant
All extract tests pass. Now let's run core tests, especially member_detection.
Assistant
All pass. Let's run the full test suite for the whole workspace to be safe.
Assistant
This test fails independent of my change (pre-existing failure, likely due to running as root where read-only permissions don't block writes). Not related to my fix. Let's continue running the rest of the workspace tests to ensure nothing else broke.
Assistant
All other tests pass; only the pre-existing unrelated failure remains. Now let's clean up temp files and review the diff.
Assistant
Good, reasonable. Now let's double check that private properties are still excluded (they are, checked earlier in the loop before reaching this code) and that constructor-parameter
inject()pattern (unlikely but let's make sure) doesn't break anything. Let's also verify the existing angular-inject-class-members fixture test still passes with cache cleared.Assistant
All good. Let's view the final diff once more and clean up.
Assistant
The change is minimal, focused, and well-tested.
Checklist review
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.