Skip to content

Commit 9eb1f86

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.
1 parent f750300 commit 9eb1f86

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
@@ -33,6 +33,7 @@ import {
3333
numberAttribute,
3434
inject,
3535
} from '@angular/core';
36+
import {type AbstractControl} from '@angular/forms';
3637
import {_getFocusedElementPierceShadowDom} from '@angular/cdk/platform';
3738
import {Observable, of as observableOf, Subject} from 'rxjs';
3839
import {startWith, takeUntil} from 'rxjs/operators';
@@ -117,7 +118,7 @@ export class CdkStep implements OnChanges {
117118
@ViewChild(TemplateRef, {static: true}) content: TemplateRef<any>;
118119

119120
/** The top level abstract control of the step. */
120-
@Input() stepControl: AbstractControlLike;
121+
@Input() stepControl: AbstractControl;
121122

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

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 { ElementRef } from '@angular/core';
@@ -12,7 +13,6 @@ import { FocusableOption } from '@angular/cdk/a11y';
1213
import * as i0 from '@angular/core';
1314
import * as i1 from '@angular/cdk/bidi';
1415
import { InjectionToken } from '@angular/core';
15-
import { Observable } from 'rxjs';
1616
import { OnChanges } from '@angular/core';
1717
import { OnDestroy } from '@angular/core';
1818
import { QueryList } from '@angular/core';
@@ -55,7 +55,7 @@ export class CdkStep implements OnChanges {
5555
select(): void;
5656
_showError(): boolean;
5757
state: StepState;
58-
stepControl: AbstractControlLike;
58+
stepControl: AbstractControl;
5959
stepLabel: CdkStepLabel;
6060
// (undocumented)
6161
_stepper: CdkStepper;

0 commit comments

Comments
 (0)