Repository navigation
Open
Description
Which @angular/* package(s) are the source of the bug?
compiler, forms
Is this a regression?
Yes
Description
Form data type like this was working earlier, but now it gives type error:
interface LoginData {
email: string | null;
password: string | null;
rememberMe: boolean;
}Form:
loginModel = signal<LoginData>({
email: null,
password: null,
rememberMe: false,
});
loginForm = form(this.loginModel);Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/f6b2smnv?file=package.json,src%2Fapp%2Fapp.ts,src%2Fapp%2Fapp.html
Please provide the exception or error you saw
[ERROR] TS2322: Type '`0x${string}` | null' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'. [plugin angular-compiler]
Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 21.1.0
Angular : 21.1.0
Node.js : 20.19.1
Package Manager : npm 10.8.2
Operating System : linux x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.1.0 │ 21.1.0 │
│ @angular/cli │ 21.1.0 │ 21.1.0 │
│ @angular/common │ 21.1.0 │ 21.1.0 │
│ @angular/compiler │ 21.1.0 │ 21.1.0 │
│ @angular/compiler-cli │ 21.1.0 │ 21.1.0 │
│ @angular/core │ 21.1.0 │ 21.1.0 │
│ @angular/forms │ 21.1.0 │ 21.1.0 │
│ @angular/platform-browser │ 21.1.0 │ 21.1.0 │
│ @angular/router │ 21.1.0 │ 21.1.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.3 │
│ zone.js │ 0.16.0 │ ~0.16.0 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else?
Also getting one other type error after 21.1.0 update (was working fine with 20.0.7 formField change), but not tried it in stackblitz so not reporting yet, getting following error with for p-datepicker component (field type Date | null):
Type 'readonly RegExp[]' is not assignable to type 'string'.ngtsc(2322)
declare (property) FormField<Date | null>.formField: InputSignal<FieldTree<Date | null, string | number>>Reacted by Konctantin, Florent Hastoy, Samuel Fernández, Larry Simon, Christian S, cciscoNet, Ananto Ghosh, Marcelo Romulo Fernandes, Johann Vanackere (OneMW), thecp and 5 more
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
geromegrignon commentedon Jan 15, 2026
The official answer about using
null:source
However as it's still pretty common in project (not stating it's a good idea), there might be some way to enhance the developer experience on such a situation.
imaksp commentedon Jan 15, 2026
I had not checked that issue before but this is from official doc:
Also this is not the major issue for me, for us it stopped compiling with custom Primeng component like p-inputNumber , p-datePicker after
21.1.0, it is giving following error:it was working fine with
21.0.7, if this is intended will need to remove signal forms usage, I was using it for trial in one of the form. (update: it was working fine till compile-cli21.0.8).[-]signal forms: string | null type stopped working with 21.1.0[/-][+]signal forms: string | null type is giving compile error, type errors while using it with primeng components[/+]Konctantin commentedon Jan 16, 2026
The impossibility of using null in real development makes signal forms useless for it.
Flaal commentedon Jan 16, 2026
Minimal reproduction of the bug with PrimeNg date-picker :
https://stackblitz.com/edit/github-vreuub4v-w9mdqzwa?file=package.json,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts
JeanMeche commentedon Feb 12, 2026
It looks like the issues with the primeNg components is solved. Thenullissue is already tracked by #65454.imaksp commentedon Feb 12, 2026
Hi @JeanMeche it seems type issue with PrimeNG and signal form is not resolved yet, for some unknown reason it now works in above stackblitz but on local it still gives same error, here is the minimal reproduction:
https://github.com/imaksp/ng-issue-66570
Steps:
pnpm install && pnpm startI have tested it with
21.1.4and21.2.0-next.3.Flaal commentedon Feb 12, 2026
Hi @imaksp, @JeanMeche, it was working on above stackblitz cause for some reasons, i accidently removed the angular compiler option "strictTemplates: true". By adding it again, the compiling error is back !
alxhub commentedon Feb 12, 2026
The error I'm seeing is unrelated to
null:TS2322: Type 'readonly RegExp[]' is not assignable to type 'string'.Is this the error in question?imaksp commentedon Feb 13, 2026
yes
bigbasti commentedon Feb 20, 2026
just updated to 21.1.5 and ran into the same issue. Is there a workaround or a fix available?
menelai commentedon Mar 2, 2026
workaround is [formField]="$any(...)"
JeevanMahesha commentedon Mar 29, 2026
The issue still persists.
DenisBalan commentedon Apr 24, 2026
Any updates on the topic?
LightBulbIdea commentedon May 6, 2026
Still an issue on Angular v.21.2.11.
This doesn't compile... I get "Type 'readonly RegExp[]' is not assignable to type 'string'.ngtsc(2322)"
<p-select [options]="dropdownOptions" [formField]="item.reportTypeId" optionLabel="label" placeholder="Select a Type" class="w-full" />This works
<p-select [options]="dropdownOptions" [formField]="$any(item.reportTypeId)" optionLabel="label" placeholder="Select a Type" class="w-full" />imaksp commentedon Jul 2, 2026
FWIW, After PrimeNG moved to closed source license based model we switched to our own form components for some (app-select, app-checkbox etc ) using ControlValueAccessor, and it works without $any hack, also apparently PrimeNG has added signal forms support in v22, so this should be lower priority now, but
string | nullorDate | nulltype should work (as per #69624 it doesn't).