Two-way binding ignores output type since angular 17.2+ · Issue #58971 · angular/angular · GitHub
Skip to content

Two-way binding ignores output type since angular 17.2+ #58971

Open

Description

@neo3587

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

When using two-way binding (aka banana-in-a-box), the output type is ignored or treated as any, after some testing it seems it started happening after v17.2.0.
This error stills happening in the current version (v19.0.1) and happens either with @Output, output or model, also happens when you bind a WritableSignal.

Example:

@Compotnent({
    selector: 'foo',
    ...
})
export class FooComponent {
    @Input() value: string | number | undefined;
    @Output() valueChange = new EventEmitter<number>();
}

@Component({
    template: `
        <foo [(value)]="str"/> <!-- ERROR: doesn't complain with 'number' is not assignable to 'string' -->
        <foo [value]="str" (valueChange)="str = $event"/> <!-- OK: complains with 'number' is not assignable to 'string' -->
    `
})
export class AppComponent {
    str: string = "";
}

Reproduction with ng17.0: https://stackblitz.com/edit/stackblitz-starters-krwib7?file=src%2Fmain.ts
Reproduction with ng17.2: https://stackblitz.com/edit/stackblitz-starters-tky4w1?file=src%2Fmain.ts

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-tky4w1?file=src%2Fmain.ts

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.2.3
Node: 18.20.3
Package Manager: npm 10.2.3
OS: linux x64

Angular: 17.2.4
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1702.3
@angular-devkit/build-angular   17.2.3
@angular-devkit/core            17.2.3
@angular-devkit/schematics      17.2.3
@angular/cli                    17.2.3
@schematics/angular             17.2.3
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.10

Anything else?

No response

Activity

  1. self-assigned this
    on Nov 29, 2024
  2. modified the milestone: needsTriage on Nov 29, 2024
  3. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Dec 4, 2024
  4. modified the milestones: needsTriage, Backlog on Dec 4, 2024
  5. crisbeto commented on Dec 6, 2024

    @crisbeto
    Member

    Following up: I've landed a fix for #59002, but it's currently disabled because it turned out to be somewhat breaking in our internal tests. We'll flip the flag to enable it in v20.

  6. removed this from the v20 candidates milestone on Apr 24, 2025
  7. added this to the Backlog milestone on Apr 24, 2025
  8. removed this from the v22 candidates milestone on Apr 27, 2026
  9. added this to the Backlog milestone on Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerbugcompiler: template type-checkingstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions