fix(forms): Value and RawValue should be part of the public API.#45978
fix(forms): Value and RawValue should be part of the public API.#45978dylhunn wants to merge 1 commit intoangular:mainfrom
Conversation
AndrewKushnir
left a comment
There was a problem hiding this comment.
Looks good (just a couple minor docs-related comments) 👍
jessicajaniuk
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@givebk-bot !donate @dylhunn $1 thanks for your PR! |
This comment was marked as off-topic.
This comment was marked as off-topic.
Consider a typed group for storing contact information:
```
declare interface ContactControls {
name: FormControl<string|null>;
}
contactForm: FormGroup<ContactControls> = ...;
saveForm(form: FormGroup<ContactControls>) {
service.newContact(contactForm.value);
}
```
What should be the type of `newContact`? The answer, of course, is the value type:
```
declare interface Contact {
name: string|null;
}
class ContactService {
newContact(c: Contact) {}
}
```
This is quite redundant, and therefore, we should allow the value type to be generated automatically. We already have the helper types to do this -- we just need to document and export them. Then, this becomes possible:
```
class ContactService {
newContact(c: RawValue<FormGroup<ContactControls>>) {}
}
```
pkozlowski-opensource
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
|
merge-assistance: this PR has the needed approvals (see above), and should be ready to merge. |
jessicajaniuk
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
|
This PR was merged into the repository by commit dba6a60. |
) Consider a typed group for storing contact information: ``` declare interface ContactControls { name: FormControl<string|null>; } contactForm: FormGroup<ContactControls> = ...; saveForm(form: FormGroup<ContactControls>) { service.newContact(contactForm.value); } ``` What should be the type of `newContact`? The answer, of course, is the value type: ``` declare interface Contact { name: string|null; } class ContactService { newContact(c: Contact) {} } ``` This is quite redundant, and therefore, we should allow the value type to be generated automatically. We already have the helper types to do this -- we just need to document and export them. Then, this becomes possible: ``` class ContactService { newContact(c: RawValue<FormGroup<ContactControls>>) {} } ``` PR Close #45978
…PI." As per discussion on #fw-forms, this reverts angular#45978 (although the more in-depth comments were kept).
|
@simonmumenthaler We merged it prematurely. It needs some additional design before we can land it and probably won't land until 14.1. |
|
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. |
Consider a typed group for storing contact information:
What should be the type of
newContact? The answer, of course, is the value type:This is quite redundant, and therefore, we should allow the value type to be generated automatically. We already have the helper types to do this -- we just need to document and export them. Then, this becomes possible:
You can even create an alias, which produces the same type as
Contactabove:This PR was filed in response to a user issue report during
14.0.0-rc.0.