feat(forms): support a generic type for ControlValueAccessor#31801
feat(forms): support a generic type for ControlValueAccessor#31801jonkoops wants to merge 1 commit intoangular:masterfrom jonkoops:feature/generic-control-value-accessor
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
Unfortunately it looks like these changes will actually incur a breaking change to the types of the public API. In some classes where I've fixed the typings for the classes that implement Perhaps adding a code mod would be appropriate to fix the problem automatically? |
|
So does this mean without the angular teams coordinating between the angular + angular/material libraries this is stuck? Is there a PR on the material side to correct this? This is arguably more important than the AbstractControl generic issues since without the ControlValueAccessor having generics you have no template side compile time safety, making the AbstractControl generics unsafe. EDIT: Also, on the topic of this change for Template side compile time safety, should we break out the default value accessor to be more type specific based on the input type? (type number is a generic of number, type text a generic of string, type checkbox a generic of Boolean) It looks like its selector can be targeted like that. |
|
@ShawnOzark That is essentially correct, however this change would not simply impact Angular Material but all libraries that make use of the ControlValueAccessor. |
|
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?
ControlValueAccessor has no support for a generic type, meaning that when implemented all methods assume a type of
any.What is the new behavior?
ControlValueAccessor now accepts an optional generic type so that all methods that are implemented from this interface receive the appropriate type.
Does this PR introduce a breaking change?
Other information
This PR is related to the following issues and requests:
registerOnChangeandregisterOnTouched(recommend closing after merge).ControlValueAccessor<T>#19340 - PR for aforementioned issue, stale and not passing CI (recommend closing after merge).