-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Forms compat Attempt 2 #64861
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
base: main
Are you sure you want to change the base?
Forms compat Attempt 2 #64861
Conversation
dea1fcb to
4f1c571
Compare
648aed0 to
d543664
Compare
| export type Subfields<TValue> = { | ||
| readonly [K in keyof TValue as TValue[K] extends Function ? never : K]: MaybeFieldTree< | ||
| TValue[K], | ||
| export type Subfields<TModel> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me what was the distinction between TModel and TValue?
I thought TModel was to be used when the value might be either the field value or a AbstractControl? In this case, shouldn't this be TValue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you changed TValue to TModel elsewhere for consistency which seems right, but unless my mental model is incorrect, this should actually be TValue here because if we're dealing with subfields, we know it's not a compat field, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like it becomes TValue here for a second, good catch
| * An error used for compat errors. | ||
| */ | ||
| export class CompatValidationError<T = unknown> implements ValidationError { | ||
| readonly kind: string = 'reactive'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense for the kind of error here to be reactive instead of compat? Since we use the term compat everywhere instead of reactive it might be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved but unchanged. Do you disagree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote for consistently using the term "compat". I don't like "reactive" because signals are reactive, and in the context of signal forms, that's the first thing I think of, not reactive forms. but whichever term we choose, we should be consistent about it
e6c2183 to
7686936
Compare
This allows using reactive form controls in signal forms
| export type Subfields<TValue> = { | ||
| readonly [K in keyof TValue as TValue[K] extends Function ? never : K]: MaybeFieldTree< | ||
| TValue[K], | ||
| export type Subfields<TModel> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you changed TValue to TModel elsewhere for consistency which seems right, but unless my mental model is incorrect, this should actually be TValue here because if we're dealing with subfields, we know it's not a compat field, right?
| * An error used for compat errors. | ||
| */ | ||
| export class CompatValidationError<T = unknown> implements ValidationError { | ||
| readonly kind: string = 'reactive'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved but unchanged. Do you disagree?
0538a83 to
a8a42a7
Compare
Now if a field contains form control, it'll unwrap its type correctly
This is more aligned with the way signal forms work, and spares user from having to deal with partial types.
|
Deployed adev-preview for 73cf1c9 to: https://ng-dev-previews-fw--pr-angular-angular-64861-adev-prev-diq1qj7n.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
In this PR we're using the same types for both compat and regular forms