Repository navigation
Closed as duplicate
Milestone
Description
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
When implementing ControlValueAccessor for a custom form control and this form component also has an input called min or max, there is a compiler error complaining about a type mismatch (see below) when used with Signal Forms. In my eyes the error is wrong.
To reproduce, open the StackBlitz example.
If the input has another name or is removed, compiling does work.
Workaround:
Wrap the formField assignment with $any(): [formField]=$any(form.control).
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-nz2vatce?file=src%2Fmain.ts
Please provide the exception or error you saw
✘ [ERROR] TS2322: Type 'Date | undefined' is not assignable to type 'Date | null'.
Type 'undefined' is not assignable to type 'Date | null'. [plugin angular-compiler]
src/main.ts:34:31:
34 │ ...mplate: `<app-date-picker [formField]="form.date"></app-date-pi...
╵ ~~~~~~~~~
Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 22.0.5
Angular : 22.0.5
Node.js : 22.22.3
Package Manager : npm 10.8.2
Operating System : linux x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.0.5 │ ^22.0.0 │
│ @angular/cli │ 22.0.5 │ ^22.0.0 │
│ @angular/common │ 22.0.5 │ ^22.0.0 │
│ @angular/compiler │ 22.0.5 │ ^22.0.0 │
│ @angular/compiler-cli │ 22.0.5 │ ^22.0.0 │
│ @angular/core │ 22.0.5 │ ^22.0.0 │
│ @angular/forms │ 22.0.5 │ ^22.0.0 │
│ @angular/platform-browser │ 22.0.5 │ ^22.0.0 │
│ @angular/router │ 22.0.5 │ ^22.0.0 │
│ rxjs │ 7.8.2 │ ^7.8.1 │
│ typescript │ 6.0.3 │ ^6.0.3 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else?
No response
Reacted by Lukas Spirig and Pablo Maurer
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
imaksp commentedon Jul 2, 2026
It works if you use
Date | undefinedinstead ofDate | null, so related to null usage with signal forms,I had tried with older version for
string | nullhere #66570,but they said its being tracked here (its closed now):
#65454
jeripeierSBB commentedon Jul 2, 2026
It works if you change the type of
mintoDate | undefined. The issue is that if the Control Value Accessor component lives in a library, you can't simply change its types.Casting to "Date | undefined" on the consuming component (in signal model) doesn't work.
JeanMeche commentedon Jul 3, 2026
This is because of the definition of
minonReadonlyFieldState: https://angular.dev/api/forms/signals/ReadonlyFieldState#minI'd consider that the limit of the interop between the CVA and FormFields. The interface will need to match because this is what the
FieldStateexposed.imaksp commentedon Jul 6, 2026
Ok, so adding
| nullto ReadonlyFieldState type (likeSignal<NonNullable<TValue> | undefined | null>) will fix this or not?jeripeierSBB commentedon Jul 6, 2026
Ok, I understand. In our case having #69452 would also improve the situation.
fix(forms): preserve CVA-owned constraint inputs
fix(forms): preserve explicit CVA constraint inputs
min/max/minLength/maxLengthtypes on custom controls #70600