ngneat / reactive-forms

(Angular Reactive) Forms with Benefits 😉

Home Page:https://www.netbasal.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integrate with Angular 14 typed forms

CristhianParra opened this issue · comments

Description

Now that angular/angular#13721 was finally solved, I think there's no longer a need for extra typings here, this project will still be useful for the additional helpers provided, but now it should be possible to leverage the type inference part to angular

Proposed solution

Delete duplicated types files

Alternatives considered

Keep the types duplicated, if current angular API is not suitable for integration with the other features of this package

Do you want to create a pull request?

No

I wonder if we could have a migration to migrate back to Angular forms.

It's not exactly the same. Angular doesn't have the ControlsOf helper, for example.

Based on my experience so far, it's easier to migrate from @ngneat/reactive-forms to ng 14 strongly typed forms than it is from ng 13 @angular/forms. Migrating from ng 13 keeps the prior lack of typing, but migrating from reactive-forms keeps the strong typing. I found it useful to replace:

import { FormControl, FormGroup } from '@ngneat/reactive-forms';
import { ValuesOf } from '@ngneat/reactive-forms/lib/types';

with

import { FormControl, FormGroup, ɵFormGroupRawValue as ValuesOf } from '@angular/forms';

I'm a fan of the @ngneat projects, but I'm also happy to reduce layers when possible.

This library developer experience is a more thoughtful than what Angular team done.
Hope they will take this project in consideration somehow.

This post on Medium may share a way to leverage ControlsOf with the new Angular strongly-typed forms