ng-stack
ng-stack copied to clipboard
@ng-stack/forms incompatible with Angular 14
After updating an Angular 13 project with @ng-stack/forms to Angular 14, the following compilation errors appear during the project compilation:
Error: node_modules/@ng-stack/forms/lib/form-builder.d.ts:27:5 - error TS2416: Property 'group' in type 'FormBuilder' is not assignable to the same property in base type 'FormBuilder'.
Type '<T extends object = any, V extends object = ValidatorsModel>(controlsConfig: { [P in keyof T]: FbControlConfig<T[P], V>; }, options?: AbstractControlOptions<any> | null | undefined) => FormGroup<...>' is not assignable to type '{ <T extends {}>(controls: T, options?: AbstractControlOptions | null | undefined): FormGroup<{ [K in keyof T]: ɵElement<T[K], null>; }>; (controls: { ...; }, options: { ...; }): FormGroup<...>; }'.
Call signature return types 'FormGroup<any, any>' and 'FormGroup<{ [x: string]: FormControl<unknown>; }>' are incompatible.
The types of 'controls' are incompatible between these types.
Type '{ [x: string]: FormGroup<any, any> | FormControl<any, any> | FormArray<any, any>; }' is not assignable to type '{ [x: string]: FormControl<unknown>; }'.
'string' index signatures are incompatible.
Type 'FormGroup<any, any> | FormControl<any, any> | FormArray<any, any>' is not assignable to type 'FormControl<unknown>'.
Type 'FormGroup<any, any>' is missing the following properties from type 'FormControl<unknown>': defaultValue, registerOnChange, registerOnDisabledChange
27 group<T extends object = any, V extends object = ValidatorsModel>(controlsConfig: {
~~~~~
Error: node_modules/@ng-stack/forms/lib/form-builder.d.ts:81:5 - error TS2416: Property 'array' in type 'FormBuilder' is not assignable to the same property in base type 'FormBuilder'.
Type '<Item = any, V extends object = ValidatorsModel>(controlsConfig: FbControlConfig<Item, V>[], validatorOrOpts?: ValidatorFn<any> | ValidatorFn<any>[] | AbstractControlOptions<...> | null | undefined, asyncValidator?: AsyncValidatorFn<...> | ... 2 more ... | undefined) => FormArray<...>' is not assignable to type '<T>(controls: T[], validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null | undefined, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null | undefined) => FormArray<...>'.
Types of parameters 'controlsConfig' and 'controls' are incompatible.
Type 'T[]' is not assignable to type 'FbControlConfig<T, ValidationErrors>[]'.
Type 'T' is not assignable to type 'FbControlConfig<T, ValidationErrors>'.
81 array<Item = any, V extends object = ValidatorsModel>(controlsConfig: FbControlConfig<Item, V>[], validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormArray<Item, V>;
~~~~~
Expected: @ng-stack/forms is compatible with Angular 14.
Angular 14 has support for strong typed forms. Do you think @ng-stack/forms
should add compatible with Angular 14?
In the long run - definitely not. But it would be nice to have an option to update Angular first and gradually migrate forms a bit later.
On Thu, Jun 30, 2022, 22:50 Костя Третяк @.***> wrote:
Angular 14 has support for strong typed forms. Do you think @ng-stack/forms should support Angular 14?
— Reply to this email directly, view it on GitHub https://github.com/KostyaTretyak/ng-stack/issues/109#issuecomment-1171614757, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAULJDVFPNDTYS24GH34NDDVRX3BXANCNFSM52JTMLVQ . You are receiving this because you authored the thread.Message ID: @.***>
This PR should resolve this issue.