New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(forms): Implement strict types for the Angular Forms package. #43834
Conversation
There are a lot of challenges in this area due to the flexibility of the API. As far as I can tell, I've written a typed version that reaches the maximum we can without breaking the API. Feel free to look at the source code: https://github.com/ngneat/reactive-forms Furthermore, it would be helpful to add specs for the types in this case. You can see an example here: |
Wonderful, somehow I wasn't aware of this. I'll be sure to have a look. |
2d42212
to
d99a19e
Compare
9cfa76c
to
5cc693e
Compare
FYI, just sharing first batch of comments, will publish more comments tomorrow.
You can preview f161700 at https://pr43834-f161700.ngbuilds.io/. |
bcce3cf
to
7959624
Compare
034ddce
to
52f9aaa
Compare
TGP is green, with two final fixup CLs patched: one, two merge-assistance: merge separately, Tuesday morning |
This PR strongly types the forms package by adding generics to AbstractControl classes as well as FormBuilder. This makes forms type-safe and null-safe, for both controls and values. The design uses a "control-types" approach. In other words, the type parameter on FormGroup is an object containing controls, and the type parameter on FormArray is an array of controls. Special thanks to Alex Rickabaugh and Andrew Kushnir for co-design & implementation, to Sonu Kapoor and Netanel Basal for illustrative prior art, and to Cédric Exbrayat for extensive testing and validation. BREAKING CHANGE: Forms classes accept a generic. Forms model classes now accept a generic type parameter. Untyped versions of these classes are available to opt-out of the new, stricter behavior.
This PR was merged into the repository by commit 89d2991. |
it's been 5+ years of wait but worth it. thanks everybody! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR strongly types the forms package by adding generics to
AbstractControl
classes as well asFormBuilder
. This makes forms type-safe and null-safe, for both controls and values.The design uses a "control-types" approach. In other words, the type parameter on
FormGroup
is an object containing controls, and the type parameter onFormArray
is a control.Issue: #13721