Skip to content

Commit 6fc7c50

Browse files
authored
refactor(multiple): run typed forms migration (#24698)
Runs the typed forms migration over all our code.
1 parent b372f68 commit 6fc7c50

File tree

100 files changed

+453
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+453
-406
lines changed

src/cdk-experimental/listbox/listbox.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
dispatchMouseEvent,
99
} from '../../cdk/testing/private';
1010
import {A, DOWN_ARROW, END, HOME, SPACE} from '@angular/cdk/keycodes';
11-
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
11+
import {UntypedFormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
1212
import {CdkCombobox, CdkComboboxModule} from '@angular/cdk-experimental/combobox';
1313

1414
describe('CdkOption and CdkListbox', () => {
@@ -967,7 +967,7 @@ class ListboxActiveDescendant {
967967
</select>`,
968968
})
969969
class ListboxControlValueAccessor {
970-
form = new FormControl();
970+
form = new UntypedFormControl();
971971
changedOption: CdkOption<string>;
972972
isDisabled: boolean = false;
973973
isMultiselectable: boolean = false;

src/cdk/testing/tests/test-main-component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import {ENTER} from '@angular/cdk/keycodes';
1010
import {_supportsShadowDom} from '@angular/cdk/platform';
11-
import {FormControl} from '@angular/forms';
11+
import {UntypedFormControl} from '@angular/forms';
1212
import {
1313
ChangeDetectionStrategy,
1414
ChangeDetectorRef,
@@ -47,7 +47,7 @@ export class TestMainComponent implements OnDestroy {
4747
_shadowDomSupported = _supportsShadowDom();
4848
clickResult = {x: -1, y: -1};
4949
rightClickResult = {x: -1, y: -1, button: -1};
50-
numberControl = new FormControl();
50+
numberControl = new UntypedFormControl();
5151

5252
@ViewChild('clickTestElement') clickTestElement: ElementRef<HTMLElement>;
5353
@ViewChild('taskStateResult') taskStateResultElement: ElementRef<HTMLElement>;

src/components-examples/cdk/stepper/cdk-linear-stepper-with-form/cdk-linear-stepper-with-form-example.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component} from '@angular/core';
22
import {CdkStepper} from '@angular/cdk/stepper';
3-
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
3+
import {UntypedFormBuilder, UntypedFormGroup, Validators} from '@angular/forms';
44

55
/** @title A custom CDK linear stepper with forms */
66
@Component({
@@ -10,10 +10,10 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms';
1010
})
1111
export class CdkLinearStepperWithFormExample {
1212
isLinear = true;
13-
firstFormGroup: FormGroup;
14-
secondFormGroup: FormGroup;
13+
firstFormGroup: UntypedFormGroup;
14+
secondFormGroup: UntypedFormGroup;
1515

16-
constructor(private readonly _formBuilder: FormBuilder) {
16+
constructor(private readonly _formBuilder: UntypedFormBuilder) {
1717
this.firstFormGroup = this._formBuilder.group({
1818
firstControl: ['', Validators.required],
1919
});

src/components-examples/material-experimental/mdc-form-field/mdc-form-field-custom-control/form-field-custom-control-example.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import {FocusMonitor} from '@angular/cdk/a11y';
22
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
33
import {Component, ElementRef, Inject, Input, OnDestroy, Optional, Self} from '@angular/core';
4-
import {ControlValueAccessor, FormBuilder, FormGroup, NgControl, Validators} from '@angular/forms';
4+
import {
5+
ControlValueAccessor,
6+
UntypedFormBuilder,
7+
UntypedFormGroup,
8+
NgControl,
9+
Validators,
10+
} from '@angular/forms';
511
import {MatFormField, MatFormFieldControl} from '@angular/material-experimental/mdc-form-field';
612
import {MAT_FORM_FIELD} from '@angular/material/form-field';
713
import {Subject} from 'rxjs';
@@ -32,7 +38,7 @@ export class MyTel {
3238
export class MyTelInput implements ControlValueAccessor, MatFormFieldControl<MyTel>, OnDestroy {
3339
static nextId = 0;
3440

35-
parts: FormGroup;
41+
parts: UntypedFormGroup;
3642
stateChanges = new Subject<void>();
3743
focused = false;
3844
errorState = false;
@@ -103,7 +109,7 @@ export class MyTelInput implements ControlValueAccessor, MatFormFieldControl<MyT
103109
}
104110

105111
constructor(
106-
formBuilder: FormBuilder,
112+
formBuilder: UntypedFormBuilder,
107113
private _focusMonitor: FocusMonitor,
108114
private _elementRef: ElementRef<HTMLElement>,
109115
@Optional() @Inject(MAT_FORM_FIELD) public _formField: MatFormField,

src/components-examples/material/autocomplete/autocomplete-auto-active-first-option/autocomplete-auto-active-first-option-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, OnInit} from '@angular/core';
2-
import {FormControl} from '@angular/forms';
2+
import {UntypedFormControl} from '@angular/forms';
33
import {Observable} from 'rxjs';
44
import {map, startWith} from 'rxjs/operators';
55

@@ -12,7 +12,7 @@ import {map, startWith} from 'rxjs/operators';
1212
styleUrls: ['autocomplete-auto-active-first-option-example.css'],
1313
})
1414
export class AutocompleteAutoActiveFirstOptionExample implements OnInit {
15-
myControl = new FormControl();
15+
myControl = new UntypedFormControl();
1616
options: string[] = ['One', 'Two', 'Three'];
1717
filteredOptions: Observable<string[]>;
1818

src/components-examples/material/autocomplete/autocomplete-display/autocomplete-display-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, OnInit} from '@angular/core';
2-
import {FormControl} from '@angular/forms';
2+
import {UntypedFormControl} from '@angular/forms';
33
import {Observable} from 'rxjs';
44
import {map, startWith} from 'rxjs/operators';
55

@@ -16,7 +16,7 @@ export interface User {
1616
styleUrls: ['autocomplete-display-example.css'],
1717
})
1818
export class AutocompleteDisplayExample implements OnInit {
19-
myControl = new FormControl();
19+
myControl = new UntypedFormControl();
2020
options: User[] = [{name: 'Mary'}, {name: 'Shelley'}, {name: 'Igor'}];
2121
filteredOptions: Observable<User[]>;
2222

src/components-examples/material/autocomplete/autocomplete-filter/autocomplete-filter-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, OnInit} from '@angular/core';
2-
import {FormControl} from '@angular/forms';
2+
import {UntypedFormControl} from '@angular/forms';
33
import {Observable} from 'rxjs';
44
import {map, startWith} from 'rxjs/operators';
55

@@ -12,7 +12,7 @@ import {map, startWith} from 'rxjs/operators';
1212
styleUrls: ['autocomplete-filter-example.css'],
1313
})
1414
export class AutocompleteFilterExample implements OnInit {
15-
myControl = new FormControl();
15+
myControl = new UntypedFormControl();
1616
options: string[] = ['One', 'Two', 'Three'];
1717
filteredOptions: Observable<string[]>;
1818

src/components-examples/material/autocomplete/autocomplete-optgroup/autocomplete-optgroup-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, OnInit} from '@angular/core';
2-
import {FormBuilder, FormGroup} from '@angular/forms';
2+
import {UntypedFormBuilder, UntypedFormGroup} from '@angular/forms';
33
import {Observable} from 'rxjs';
44
import {startWith, map} from 'rxjs/operators';
55

@@ -22,7 +22,7 @@ export const _filter = (opt: string[], value: string): string[] => {
2222
templateUrl: 'autocomplete-optgroup-example.html',
2323
})
2424
export class AutocompleteOptgroupExample implements OnInit {
25-
stateForm: FormGroup = this._formBuilder.group({
25+
stateForm: UntypedFormGroup = this._formBuilder.group({
2626
stateGroup: '',
2727
});
2828

@@ -125,7 +125,7 @@ export class AutocompleteOptgroupExample implements OnInit {
125125

126126
stateGroupOptions: Observable<StateGroup[]>;
127127

128-
constructor(private _formBuilder: FormBuilder) {}
128+
constructor(private _formBuilder: UntypedFormBuilder) {}
129129

130130
ngOnInit() {
131131
this.stateGroupOptions = this.stateForm.get('stateGroup')!.valueChanges.pipe(

src/components-examples/material/autocomplete/autocomplete-overview/autocomplete-overview-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {FormControl} from '@angular/forms';
2+
import {UntypedFormControl} from '@angular/forms';
33
import {Observable} from 'rxjs';
44
import {map, startWith} from 'rxjs/operators';
55

@@ -18,7 +18,7 @@ export interface State {
1818
styleUrls: ['autocomplete-overview-example.css'],
1919
})
2020
export class AutocompleteOverviewExample {
21-
stateCtrl = new FormControl();
21+
stateCtrl = new UntypedFormControl();
2222
filteredStates: Observable<State[]>;
2323

2424
states: State[] = [

src/components-examples/material/autocomplete/autocomplete-plain-input/autocomplete-plain-input-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, OnInit} from '@angular/core';
2-
import {FormControl} from '@angular/forms';
2+
import {UntypedFormControl} from '@angular/forms';
33
import {Observable} from 'rxjs';
44
import {startWith, map} from 'rxjs/operators';
55

@@ -12,7 +12,7 @@ import {startWith, map} from 'rxjs/operators';
1212
styleUrls: ['autocomplete-plain-input-example.css'],
1313
})
1414
export class AutocompletePlainInputExample implements OnInit {
15-
control = new FormControl();
15+
control = new UntypedFormControl();
1616
streets: string[] = ['Champs-Élysées', 'Lombard Street', 'Abbey Road', 'Fifth Avenue'];
1717
filteredStreets: Observable<string[]>;
1818

0 commit comments

Comments
 (0)