2

I am getting the below error when using Typed Reactive Forms in Angular 14 and I have defined a type that maps a model to a strict form group. The error only occurs when using the Date or Blob type. PS: I use Angular 14.

Error: src/app/sumarios/submission-sumario/submission-sumario.component.ts:903:7 - error TS2740: Type 'FormControl<Date>' is missing the following properties from type 'FormGroup<ControlsOf<Date>>': controls, registerControl, addControl, removeControl, and 2 more.

903       dataCriacao: new FormControl(sumario.dataCriacao),

Source:

export type ControlsOf<T extends Record<any, any>> = {
  [P in keyof T]?: T[P] extends Record<any, any>
  ? T[P] extends (infer U)[] ? (U extends Record<any, any> ? FormArray<FormGroup<ControlsOf<U>>> : FormArray<FormControl<U>>) : FormGroup<ControlsOf<T[P]>>
  : FormControl<T[P]>
}

enter image description here

Class:

enter image description here

[EDIT]

Here is the basic example demonstrating the error

2
  • Please provide enough code so others can better understand or reproduce the problem. Commented Sep 28, 2022 at 11:57
  • I've included the example link above on stackblitz. Commented Sep 28, 2022 at 23:12

1 Answer 1

1

Do ControlsOf is your concern? If not, you can try to replace with ngx-mf.

Here is example stackblitz

Here is more information about: 4 Problems of Angular 14 Typed Forms and How to Fix Them

Sign up to request clarification or add additional context in comments.

2 Comments

yes, it seems that the function only recognizes primitive type and class. The object, such as Date or Blob, does not. It seems that you have to adjust the function to recognize object.
I've included the example link above on stackblitz.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.