SWE-Rebench v2 hard task
harbor run -t ibragim-badertdinov/fallow-rs__fallow-913harbor download ibragim-badertdinov/fallow-rs__fallow-913service member referenced in an Angular external template is reported as unused when the component property is initialized with inject() (no explicit type annotation)
With the angular plugin active, fallow dead-code reports a service method as an
unused class member when its only reference is in an Angular HTML template
(prop.method()), and the component property prop is initialized with the modern
inject() 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.
Minimal standalone repro. @angular/core only needs to be listed in package.json so the
angular plugin auto-activates — running npm install is 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);
Create src/example.service.ts:
import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class ExampleService {
// Only referenced from example.component.html via an event binding.
onValueChange(value: string): void {
console.log(value);
}
}
Create src/example.component.ts:
import { Component, inject } from '@angular/core';
import { ExampleService } from './example.service';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
})
export class ExampleComponent {
// Exposed to the template so the binding can call exampleService.onValueChange(...)
readonly exampleService = inject(ExampleService);
}
Create src/example.component.html:
<input (input)="exampleService.onValueChange($event.target.value)" />
Run:
npx fallow dead-code --config .fallowrc.json
── Unused Code ─────────────────────────────────────
● Unused class members (1)
src/example.service.ts
:6 ExampleService.onValueChange
Class methods or properties never referenced outside their class
✗ 1 class member
onValueChange is reported as unused even though it is referenced in
example.component.html.
Keeping the template (input)="exampleService.onValueChange(...)" unchanged and only varying
how exampleService is declared on the component:
inject() field with
constructor(public exampleService: ExampleService) {}. Result: ✓ No issues found.inject() with an explicit type annotation:
readonly exampleService: ExampleService = inject(ExampleService);. Result:
✓ No issues found.new initializer: readonly exampleService = new ExampleService();.
Result: ✓ No issues found.Only the untyped inject() initializer (the repro above) produces the false positive. This
points at the component-property → service-type binding step: it resolves type annotations,
constructor parameters, and new expressions, but not an untyped inject() initializer, so
the template reference exampleService.onValueChange is never credited to ExampleService.
A service member referenced from an Angular template via a component property should be
credited as used when that property is initialized with inject() — the same way it already
is for typed inject(), constructor injection, and new initializers. No
unused-class-member finding should be reported in the repro above.
fallow 2.83.0
macOS
default
No new interfaces are introduced.