Skip to content

Instantly share code, notes, and snippets.

@twerske
Created May 13, 2022 17:32
Show Gist options
  • Save twerske/6a9055e3bcf1ef868d30f86441ffd41b to your computer and use it in GitHub Desktop.
Save twerske/6a9055e3bcf1ef868d30f86441ffd41b to your computer and use it in GitHub Desktop.
Update schematics allows for incremental migration to typed forms
// v13 untyped form
const cat = new FormGroup({
name: new FormGroup(
first: new FormControl('Barb'),
last: new FormControl('Smith'),
),
lives: new FormControl(9)
});
// v14 untyped form after running `ng update`
const cat = new UntypedFormGroup({
name: new UntypedFormGroup(
first: new UntypedFormControl('Barb'),
last: new UntypedFormControl('Smith'),
),
lives: new UntypedFormControl(9)
});
Copy link

ghost commented Jan 27, 2023

@twerske, you are missing some curly brackets in the example:

 // v13 untyped form
 const cat = new FormGroup({
-   name: new FormGroup(
+   name: new FormGroup({
       first: new FormControl('Barb'),
       last: new FormControl('Smith'),
-   ),
+   }),
    lives: new FormControl(9)
 });
 
 // v14 untyped form after running `ng update`
 const cat = new UntypedFormGroup({
-   name: new UntypedFormGroup(
+   name: new UntypedFormGroup({
       first: new UntypedFormControl('Barb'),
       last: new UntypedFormControl('Smith'),
-   ),
+   }),
    lives: new UntypedFormControl(9)
 });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment