Skip to content

Experimental: Strictly typed reactive forms #38406

Closed
sonukapoor wants to merge 13 commits intoangular:masterfrom
sonukapoor:strictly_types_reactive_forms
Closed

Experimental: Strictly typed reactive forms #38406
sonukapoor wants to merge 13 commits intoangular:masterfrom
sonukapoor:strictly_types_reactive_forms

Conversation

@sonukapoor
Copy link
Contributor

Based on the original work from #37389

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@sonukapoor sonukapoor added area: forms forms: Controls API Issues related to AbstractControl, FormControl, FormGroup, FormArray. labels Aug 11, 2020
@ngbot ngbot bot modified the milestone: needsTriage Aug 11, 2020
@AndrewKushnir
Copy link
Contributor

Presubmit.

@angular angular deleted a comment from googlebot Aug 11, 2020
@sonukapoor sonukapoor force-pushed the strictly_types_reactive_forms branch from 40607b1 to 50a99bf Compare August 11, 2020 10:57
@sonukapoor sonukapoor force-pushed the strictly_types_reactive_forms branch 2 times, most recently from 42eb11c to a4abb47 Compare August 11, 2020 11:17
@sonukapoor sonukapoor changed the title Experimental and test only - Strictly types reactive forms Experimental and test only - Strictly typed reactive forms Aug 11, 2020
@googlebot

This comment has been minimized.

@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented Aug 11, 2020

Hi,

Quick update after running tests in Google's codebase: this change is breaking a portion of targets.

I performed initial investigation and it looks like a lot of targets are failing with a similar error and we also have this scenario in tests:

const c = new FormControl(null, {validators});
c.setValue('value');

TypeScript infers the generic type (T) as null, thus the setValue call argument with the string type produces an error. In the tests this is solved by adding the <string> generic type, i.e.:

const c = new FormControl<string>(null, {validators});
c.setValue('value');

It'd be great to investigate if adding a generic type can be avoided in this case (without loosing type safety) - it should reduce the number of failing targets and simplify the migration for users.

Thank you.

@angular angular deleted a comment from googlebot Aug 11, 2020
@angular angular deleted a comment from googlebot Aug 11, 2020
@googlebot

This comment has been minimized.

@sonukapoor sonukapoor force-pushed the strictly_types_reactive_forms branch 2 times, most recently from b0cfde2 to 623004d Compare August 21, 2020 12:30
@AndrewKushnir AndrewKushnir force-pushed the strictly_types_reactive_forms branch from d8035b4 to 6bb0e5e Compare April 1, 2021 01:56
@google-cla
Copy link

google-cla bot commented Apr 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Apr 1, 2021
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Apr 1, 2021
@AndrewKushnir
Copy link
Contributor

Presubmit.

const input = fixture.debugElement.query(By.css('input'));
form.valueChanges.subscribe({
next: (value) => {
next: (value: any) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unknown instead of any could be better here

@atscott
Copy link
Contributor

atscott commented Dec 16, 2021

Closing since this is being actively worked on by @dylhunn as part of the typed forms project (#43834, #44513)

@atscott atscott closed this Dec 16, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: forms cla: yes forms: Controls API Issues related to AbstractControl, FormControl, FormGroup, FormArray.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants