fix(forms): fix FormRecord type inference - #50752
EmmanuelRoux wants to merge 4 commits into
Conversation
46d5b75 to
1bd1ae6
Compare
Updates type inference in `ɵElement` to make `FormRecord` take precedence over `FormGroup`
Add a marker property to `FormRecord` to make its type actually different from `FormGroup`
1bd1ae6 to
961bf32
Compare
|
cc @dylhunn You might wanna take a look at this 👍 |
Add ɵ as prefix to internal property
Simplify brand property and avoid value assignment
|
Up 🙂 @dylhunn |
|
Interesting. Can you show an example of an inference that would have been broken under the previous regime? It would be good to add it to |
|
@dylhunn you can take a look at the failed test in this PR : #50750 A |
|
@EmmanuelRoux If this PR provides a fix it should also introduce a previously broken test ! |
|
@JeanMeche This is why I provided a link to #50750 : Currently, this does NOT break anything, because type X = ɵElement<FormRecord<FormControl<string>>, null>;
// X is currently inferred as FormGroup<{[p: string]: FormControl<string>}>
const formGroupX: X = null!;
const formGroupY: FormGroup<{[p: string]: FormControl<string>}> = a;
const formRecordZ: FormRecord<FormControl<string>> = a; // <-- Currently no error, because FormGroup can be assigned to FormRecordBUT, if // Let's imagine FormRecord has a new method, for example:
export interface FormRecord<TControl> {
// ...
someMethod(): TControl;
}
// Then this would break (as expected) :
const formGroupX: X = null!;
const formGroupY: FormGroup<{[p: string]: FormControl<string>}> = a;
const formRecordZ: FormRecord<FormControl<string>> = a; // <-- Error, because FormGroup cannot be assigned to FormRecordThis is exactly what the PR #50750 aims to introduce. |
|
This is for the sake of commit tree grooming. That we'd like to have tests covering bugfixes / feature introductions. Either this PR should introduce new test, which shows the fix its bringing or the PR should be merged with #50750. |
|
@JeanMeche @dylhunn merged with #50750 |
|
Any update on this PR or #50750 please ? |
|
I'll close this in favor of #50750 which is getting reviewed and tested. |
|
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?
Issue Number: #50751
What is the new behavior?
Does this PR introduce a breaking change?
Other information