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): make reactive forms strongly typed #37389
Conversation
@AndrewKushnir, please tell me why you set "flag: breaking change"? |
Good news! After sleep, I see why "flag: breaking change" is set here =). This is not a runtime breaking change, but only by type. |
Hi @KostyaTretyak, thanks for creating this PR! We will review it and provide the feedback.
I've added the "flag: breaking change" flag since there are changes to the public API that may not be backwards-compatible. For example this change to the Thank you. |
168300b
to
ade22d5
Compare
I tried to run
If anyone knows how to fix this, please tell me how. |
d648343
to
c535e57
Compare
It remains to fix one error. This error, as far as I understand, should be fixed on the angular/components repo. |
@KostyaTretyak If you need any help with this PR I am willing to help out. Perhaps my PR for supporting a generic type for |
- introduce form control typed - added generics for form builder - added FormState<T> and FormControlConfig<T> types
After introduce form control generics, fixed breaking changes: - form group/array control need type hint like this `FormGroup<type>` sometimes
…y.value - added generic for abstractControl.get() - removed null as allowed value for formGroup/formArray value
Because the FormState type is actually intended for FormControl constructor, FormState is renamed to FormControlState.
@KostyaTretyak, it looks like you also need to run # start with a clean slate, if you want to.
# rm -rf aio/node_modules
yarn --cwd aio install But then you run into other issues, so you need to also run:
And only then, the Checkout the "Developer tasks" section in aio/README.md. Maybe these |
Thanks for the updates in this PR @KostyaTretyak and thanks @SchnWalter for providing feedback As Kara mentioned in #13721 (comment), we'll start looking into Form type improvements soon (we don't have an exact ETA at this moment). Meanwhile I've collected all types-related PRs in the Forms type improvements Milestone on Github, so we can take them (including comments) into account.
I think it makes sense to have multiple individual PRs targeting subsets of Forms package, so it's easier to review, test and merge (in master branch as well as in Google codebase internally). We'll provide more updates as soon as we have them. Thank you. |
ccb906f
to
fee6974
Compare
Due to the HTML binding issues noted in issue #36405, it would be nice if the typings on I.e. instead of: FormArray - The generics were something like: If possible I think that would resolve a lot of work-arounds currently needed, especially since it appears angular 10 is more aggressive with |
My opinion on this can be read in this discussion. |
Hi @KostyaTretyak, Quick update: while this task is in our Backlog at this moment (i.e. we have not started active work on it) I ran tests in Google's codebase with the changes from this PR. As we expected, it's breaking a relatively big number of apps, so landing this PR with the current set of changes would be difficult (since that would require adapting apps code to this change). This also indicates that landing this PR on NPM (as a part of a major release) would require Forms users to adapt their apps during the upgrade as well. This is expected for some breaking changes (where creating a schematic is not feasible or a breaking change is affecting a small portion of the codebase and the fix is straightforward), but we always try to minimize the impact of breaking changes to provide a smooth upgrade experience. The changes in this PR are very useful and I'd like to propose splitting this PR into a set of smaller PRs and try to land them in the following sequence (each group might have more than one PR):
Please let me know your opinion on how the changes in this PR can be split and whether we can extract some backwards-compatible changes into separate PR(s). Thank you. |
Unfortunately, I will not be able to take the time to improve this Pull Request in the near future. |
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Weak typechecking for reactive forms.
Issue Number: #13721
Does this PR introduce a breaking change?