bug(Datepicker): Signal Forms - [Error] TS2322: Type 'Date' is not assignable to type 'string'.
Is this a regression?
- [ ] Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
If I try to use Datepicker similar to this example from Setting the selected date but with signal forms i get a compile time error:
✘ [ERROR] TS2322: Type 'Date' is not assignable to type 'string'. [plugin angular-compiler]
src/example/datepicker-value-example.html:28:53:
28 │ <input matInput [matDatepicker]="picker4" [field]="form.date">
╵ ~~~~~~~~~
Error occurs in the template of component DatepickerValueExample.
src/example/datepicker-value-example.ts:12:15:
12 │ templateUrl: 'datepicker-value-example.html',
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reproduction
StackBlitz link: https://stackblitz.com/edit/zzkeckx2?file=src%2Fexample%2Fdatepicker-value-example.ts,src%2Fexample%2Fdatepicker-value-example.html&startScript=start
Expected Behavior
No compile time error when using Datepicker with DateAdapter and [field] directive.
Actual Behavior
TS2322: Type 'Date' is not assignable to type 'string'.
Environment
- Angular: 21.0.1
- CDK/Material: 21.0.1
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):
Fixed in the compiler by https://github.com/angular/angular/pull/65469.
@crisbeto Shouldn't it work then on stackblitz with latest version 21.0.1?
Yeah the fix is in 21.0.1, but I'm not sure if the Stackblitz actually installed it.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.