Skip to content

Commit fa43a24

Browse files
committed
fix(cdk/stepper): remove mock of forms type
Previously we were mocking out the `AbstractControl` type, because we didn't want to bring in additional code for the optional forms integration. That's no longer necessary, because we can use type-only imports. (cherry picked from commit 9eb1f86)
1 parent 104b593 commit fa43a24

File tree

2 files changed

+4
-54
lines changed

2 files changed

+4
-54
lines changed

src/cdk/stepper/stepper.ts

+2-52
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
booleanAttribute,
3636
numberAttribute,
3737
} from '@angular/core';
38+
import {type AbstractControl} from '@angular/forms';
3839
import {_getFocusedElementPierceShadowDom} from '@angular/cdk/platform';
3940
import {Observable, of as observableOf, Subject} from 'rxjs';
4041
import {startWith, takeUntil} from 'rxjs/operators';
@@ -118,7 +119,7 @@ export class CdkStep implements OnChanges {
118119
@ViewChild(TemplateRef, {static: true}) content: TemplateRef<any>;
119120

120121
/** The top level abstract control of the step. */
121-
@Input() stepControl: AbstractControlLike;
122+
@Input() stepControl: AbstractControl;
122123

123124
/** Whether user has attempted to move away from the step. */
124125
interacted = false;
@@ -558,54 +559,3 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy {
558559
return index > -1 && (!this.steps || index < this.steps.length);
559560
}
560561
}
561-
562-
/**
563-
* Simplified representation of an "AbstractControl" from @angular/forms.
564-
* Used to avoid having to bring in @angular/forms for a single optional interface.
565-
* @docs-private
566-
*/
567-
interface AbstractControlLike {
568-
asyncValidator: ((control: any) => any) | null;
569-
dirty: boolean;
570-
disabled: boolean;
571-
enabled: boolean;
572-
errors: {[key: string]: any} | null;
573-
invalid: boolean;
574-
parent: any;
575-
pending: boolean;
576-
pristine: boolean;
577-
root: AbstractControlLike;
578-
status: string;
579-
readonly statusChanges: Observable<any>;
580-
touched: boolean;
581-
untouched: boolean;
582-
updateOn: any;
583-
valid: boolean;
584-
validator: ((control: any) => any) | null;
585-
value: any;
586-
readonly valueChanges: Observable<any>;
587-
clearAsyncValidators(): void;
588-
clearValidators(): void;
589-
disable(opts?: any): void;
590-
enable(opts?: any): void;
591-
get(path: (string | number)[] | string): AbstractControlLike | null;
592-
getError(errorCode: string, path?: (string | number)[] | string): any;
593-
hasError(errorCode: string, path?: (string | number)[] | string): boolean;
594-
markAllAsTouched(): void;
595-
markAsDirty(opts?: any): void;
596-
markAsPending(opts?: any): void;
597-
markAsPristine(opts?: any): void;
598-
markAsTouched(opts?: any): void;
599-
markAsUntouched(opts?: any): void;
600-
patchValue(value: any, options?: Object): void;
601-
reset(value?: any, options?: Object): void;
602-
setAsyncValidators(newValidator: (control: any) => any | ((control: any) => any)[] | null): void;
603-
setErrors(errors: {[key: string]: any} | null, opts?: any): void;
604-
setParent(parent: any): void;
605-
setValidators(newValidator: (control: any) => any | ((control: any) => any)[] | null): void;
606-
setValue(value: any, options?: Object): void;
607-
updateValueAndValidity(opts?: any): void;
608-
patchValue(value: any, options?: any): void;
609-
reset(formState?: any, options?: any): void;
610-
setValue(value: any, options?: any): void;
611-
}

tools/public_api_guard/cdk/stepper.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
```ts
66

7+
import { AbstractControl } from '@angular/forms';
78
import { AfterContentInit } from '@angular/core';
89
import { AfterViewInit } from '@angular/core';
910
import { ChangeDetectorRef } from '@angular/core';
@@ -14,7 +15,6 @@ import { FocusableOption } from '@angular/cdk/a11y';
1415
import * as i0 from '@angular/core';
1516
import * as i1 from '@angular/cdk/bidi';
1617
import { InjectionToken } from '@angular/core';
17-
import { Observable } from 'rxjs';
1818
import { OnChanges } from '@angular/core';
1919
import { OnDestroy } from '@angular/core';
2020
import { QueryList } from '@angular/core';
@@ -57,7 +57,7 @@ export class CdkStep implements OnChanges {
5757
select(): void;
5858
_showError(): boolean;
5959
state: StepState;
60-
stepControl: AbstractControlLike;
60+
stepControl: AbstractControl;
6161
stepLabel: CdkStepLabel;
6262
// (undocumented)
6363
_stepper: CdkStepper;

0 commit comments

Comments
 (0)