Skip to content

Commit 09f7578

Browse files
devversionandrewseguin
authored andcommitted
build: validate CDK public API using ts-api-guardian (#14131)
1 parent 096391d commit 09f7578

23 files changed

+1891
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090

9191
# TODO(jelbourn): Update this command to run all tests if the Bazel issues have been fixed.
9292
- run: bazel build src/...
93-
- run: bazel test src/...
93+
- run: bazel test src/... tools/public_api_guard/...
9494

9595
# ------------------------------------------------------------------------------------------
9696
# Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless).

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ http_archive(
1717
# Add Angular source and Bazel rules.
1818
http_archive(
1919
name = "angular",
20-
url = "https://github.com/angular/angular/archive/7.0.3.zip",
21-
strip_prefix = "angular-7.0.3",
20+
url = "https://github.com/angular/angular/archive/2ec05415e24137d44f24b07202c34c5054c968ed.zip",
21+
strip_prefix = "angular-2ec05415e24137d44f24b07202c34c5054c968ed",
2222
)
2323

2424
# Add RxJS as repository because those are needed in order to build Angular from source.

tools/public_api_guard/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package(default_visibility=["//visibility:public"])
2+
3+
load(":generate-guard-tests.bzl", "generate_test_targets")
4+
5+
# TODO(devversion): This currently does not include the CDK portal package because
6+
# aliases are not supported by ts-api-guardian. Re-add once we found a solution for that.
7+
8+
# Generate the API guard test targets for each golden file in the current package.
9+
generate_test_targets(glob(["**/*.d.ts"]))

tools/public_api_guard/cdk/a11y.d.ts

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
export declare class A11yModule {
2+
}
3+
4+
export declare class ActiveDescendantKeyManager<T> extends ListKeyManager<Highlightable & T> {
5+
setActiveItem(index: number): void;
6+
setActiveItem(item: T): void;
7+
}
8+
9+
export declare const ARIA_DESCRIBER_PROVIDER: {
10+
provide: typeof AriaDescriber;
11+
deps: (Optional[] | InjectionToken<any>)[];
12+
useFactory: typeof ARIA_DESCRIBER_PROVIDER_FACTORY;
13+
};
14+
15+
export declare function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher: AriaDescriber, _document: any): AriaDescriber;
16+
17+
export declare class AriaDescriber implements OnDestroy {
18+
constructor(_document: any);
19+
describe(hostElement: Element, message: string): void;
20+
ngOnDestroy(): void;
21+
removeDescription(hostElement: Element, message: string): void;
22+
}
23+
24+
export declare type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
25+
26+
export declare const CDK_DESCRIBEDBY_HOST_ATTRIBUTE = "cdk-describedby-host";
27+
28+
export declare const CDK_DESCRIBEDBY_ID_PREFIX = "cdk-describedby-message";
29+
30+
export declare class CdkAriaLive implements OnDestroy {
31+
politeness: AriaLivePoliteness;
32+
constructor(_elementRef: ElementRef, _liveAnnouncer: LiveAnnouncer, _contentObserver: ContentObserver, _ngZone: NgZone);
33+
ngOnDestroy(): void;
34+
}
35+
36+
export declare class CdkMonitorFocus implements OnDestroy {
37+
cdkFocusChange: EventEmitter<FocusOrigin>;
38+
constructor(_elementRef: ElementRef<HTMLElement>, _focusMonitor: FocusMonitor);
39+
ngOnDestroy(): void;
40+
}
41+
42+
export declare class CdkTrapFocus implements OnDestroy, AfterContentInit, DoCheck {
43+
autoCapture: boolean;
44+
enabled: boolean;
45+
focusTrap: FocusTrap;
46+
constructor(_elementRef: ElementRef<HTMLElement>, _focusTrapFactory: FocusTrapFactory, _document: any);
47+
ngAfterContentInit(): void;
48+
ngDoCheck(): void;
49+
ngOnDestroy(): void;
50+
}
51+
52+
export declare const FOCUS_MONITOR_PROVIDER: {
53+
provide: typeof FocusMonitor;
54+
deps: (Optional[] | typeof NgZone | typeof Platform)[];
55+
useFactory: typeof FOCUS_MONITOR_PROVIDER_FACTORY;
56+
};
57+
58+
export declare function FOCUS_MONITOR_PROVIDER_FACTORY(parentDispatcher: FocusMonitor, ngZone: NgZone, platform: Platform): FocusMonitor;
59+
60+
export interface FocusableOption extends ListKeyManagerOption {
61+
focus(origin?: FocusOrigin): void;
62+
}
63+
64+
export declare class FocusKeyManager<T> extends ListKeyManager<FocusableOption & T> {
65+
setActiveItem(index: number): void;
66+
setActiveItem(item: T): void;
67+
setFocusOrigin(origin: FocusOrigin): this;
68+
}
69+
70+
export declare class FocusMonitor implements OnDestroy {
71+
constructor(_ngZone: NgZone, _platform: Platform);
72+
_onBlur(event: FocusEvent, element: HTMLElement): void;
73+
focusVia(element: ElementRef<HTMLElement>, origin: FocusOrigin, options?: FocusOptions): void;
74+
focusVia(element: HTMLElement, origin: FocusOrigin, options?: FocusOptions): void;
75+
monitor(element: HTMLElement, checkChildren?: boolean): Observable<FocusOrigin>;
76+
monitor(element: ElementRef<HTMLElement>, checkChildren?: boolean): Observable<FocusOrigin>;
77+
ngOnDestroy(): void;
78+
stopMonitoring(element: ElementRef<HTMLElement>): void;
79+
stopMonitoring(element: HTMLElement): void;
80+
}
81+
82+
export interface FocusOptions {
83+
preventScroll?: boolean;
84+
}
85+
86+
export declare type FocusOrigin = 'touch' | 'mouse' | 'keyboard' | 'program' | null;
87+
88+
export declare class FocusTrap {
89+
enabled: boolean;
90+
constructor(_element: HTMLElement, _checker: InteractivityChecker, _ngZone: NgZone, _document: Document, deferAnchors?: boolean);
91+
attachAnchors(): boolean;
92+
destroy(): void;
93+
focusFirstTabbableElement(): boolean;
94+
focusFirstTabbableElementWhenReady(): Promise<boolean>;
95+
focusInitialElement(): boolean;
96+
focusInitialElementWhenReady(): Promise<boolean>;
97+
focusLastTabbableElement(): boolean;
98+
focusLastTabbableElementWhenReady(): Promise<boolean>;
99+
hasAttached(): boolean;
100+
}
101+
102+
export declare class FocusTrapFactory {
103+
constructor(_checker: InteractivityChecker, _ngZone: NgZone, _document: any);
104+
create(element: HTMLElement, deferCaptureElements?: boolean): FocusTrap;
105+
}
106+
107+
export interface Highlightable extends ListKeyManagerOption {
108+
setActiveStyles(): void;
109+
setInactiveStyles(): void;
110+
}
111+
112+
export declare class InteractivityChecker {
113+
constructor(_platform: Platform);
114+
isDisabled(element: HTMLElement): boolean;
115+
isFocusable(element: HTMLElement): boolean;
116+
isTabbable(element: HTMLElement): boolean;
117+
isVisible(element: HTMLElement): boolean;
118+
}
119+
120+
export declare function isFakeMousedownFromScreenReader(event: MouseEvent): boolean;
121+
122+
export declare class ListKeyManager<T extends ListKeyManagerOption> {
123+
readonly activeItem: T | null;
124+
readonly activeItemIndex: number | null;
125+
change: Subject<number>;
126+
tabOut: Subject<void>;
127+
constructor(_items: QueryList<T> | T[]);
128+
onKeydown(event: KeyboardEvent): void;
129+
setActiveItem(index: number): void;
130+
setActiveItem(item: T): void;
131+
setFirstItemActive(): void;
132+
setLastItemActive(): void;
133+
setNextItemActive(): void;
134+
setPreviousItemActive(): void;
135+
skipPredicate(predicate: (item: T) => boolean): this;
136+
updateActiveItem(item: T): void;
137+
updateActiveItem(index: number): void;
138+
updateActiveItemIndex(index: number): void;
139+
withAllowedModifierKeys(keys: ListKeyManagerModifierKey[]): this;
140+
withHorizontalOrientation(direction: 'ltr' | 'rtl' | null): this;
141+
withTypeAhead(debounceInterval?: number): this;
142+
withVerticalOrientation(enabled?: boolean): this;
143+
withWrap(shouldWrap?: boolean): this;
144+
}
145+
146+
export declare type ListKeyManagerModifierKey = 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey';
147+
148+
export interface ListKeyManagerOption {
149+
disabled?: boolean;
150+
getLabel?(): string;
151+
}
152+
153+
export declare const LIVE_ANNOUNCER_ELEMENT_TOKEN: InjectionToken<HTMLElement | null>;
154+
155+
export declare function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY(): null;
156+
157+
export declare const LIVE_ANNOUNCER_PROVIDER: Provider;
158+
159+
export declare function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentDispatcher: LiveAnnouncer, liveElement: any, _document: any, ngZone: NgZone): LiveAnnouncer;
160+
161+
export declare class LiveAnnouncer implements OnDestroy {
162+
constructor(elementToken: any, _ngZone: NgZone, _document: any);
163+
announce(message: string): Promise<void>;
164+
announce(message: string, duration?: number): Promise<void>;
165+
announce(message: string, politeness?: AriaLivePoliteness, duration?: number): Promise<void>;
166+
announce(message: string, politeness?: AriaLivePoliteness): Promise<void>;
167+
clear(): void;
168+
ngOnDestroy(): void;
169+
}
170+
171+
export declare const MESSAGES_CONTAINER_ID = "cdk-describedby-message-container";
172+
173+
export interface RegisteredMessage {
174+
messageElement: Element;
175+
referenceCount: number;
176+
}
177+
178+
export declare const TOUCH_BUFFER_MS = 650;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export declare class CdkAccordion implements OnDestroy, OnChanges {
2+
readonly _openCloseAllActions: Subject<boolean>;
3+
readonly _stateChanges: Subject<SimpleChanges>;
4+
readonly id: string;
5+
multi: boolean;
6+
closeAll(): void;
7+
ngOnChanges(changes: SimpleChanges): void;
8+
ngOnDestroy(): void;
9+
openAll(): void;
10+
}
11+
12+
export declare class CdkAccordionItem implements OnDestroy {
13+
protected _expansionDispatcher: UniqueSelectionDispatcher;
14+
accordion: CdkAccordion;
15+
closed: EventEmitter<void>;
16+
destroyed: EventEmitter<void>;
17+
disabled: any;
18+
expanded: any;
19+
expandedChange: EventEmitter<boolean>;
20+
readonly id: string;
21+
opened: EventEmitter<void>;
22+
constructor(accordion: CdkAccordion, _changeDetectorRef: ChangeDetectorRef, _expansionDispatcher: UniqueSelectionDispatcher);
23+
close(): void;
24+
ngOnDestroy(): void;
25+
open(): void;
26+
toggle(): void;
27+
}
28+
29+
export declare class CdkAccordionModule {
30+
}

tools/public_api_guard/cdk/bidi.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export declare class BidiModule {
2+
}
3+
4+
export declare class Dir implements Directionality, AfterContentInit, OnDestroy {
5+
_rawDir: string;
6+
change: EventEmitter<Direction>;
7+
dir: Direction;
8+
readonly value: Direction;
9+
ngAfterContentInit(): void;
10+
ngOnDestroy(): void;
11+
}
12+
13+
export declare const DIR_DOCUMENT: InjectionToken<Document>;
14+
15+
export declare type Direction = 'ltr' | 'rtl';
16+
17+
export declare class Directionality implements OnDestroy {
18+
readonly change: EventEmitter<Direction>;
19+
readonly value: Direction;
20+
constructor(_document?: any);
21+
ngOnDestroy(): void;
22+
}

tools/public_api_guard/cdk/cdk.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare const VERSION: Version;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export declare function _isNumberValue(value: any): boolean;
2+
3+
export declare function coerceArray<T>(value: T | T[]): T[];
4+
5+
export declare function coerceBooleanProperty(value: any): boolean;
6+
7+
export declare function coerceCssPixelValue(value: any): string;
8+
9+
export declare function coerceNumberProperty(value: any): number;
10+
export declare function coerceNumberProperty<D>(value: any, fallback: D): number | D;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
export declare class ArrayDataSource<T> extends DataSource<T> {
2+
constructor(_data: T[] | ReadonlyArray<T> | Observable<T[] | ReadonlyArray<T>>);
3+
connect(): Observable<T[] | ReadonlyArray<T>>;
4+
disconnect(): void;
5+
}
6+
7+
export interface CollectionViewer {
8+
viewChange: Observable<ListRange>;
9+
}
10+
11+
export declare abstract class DataSource<T> {
12+
abstract connect(collectionViewer: CollectionViewer): Observable<T[] | ReadonlyArray<T>>;
13+
abstract disconnect(collectionViewer: CollectionViewer): void;
14+
}
15+
16+
export declare function getMultipleValuesInSingleSelectionError(): Error;
17+
18+
export declare type ListRange = {
19+
start: number;
20+
end: number;
21+
};
22+
23+
export interface SelectionChange<T> {
24+
added: T[];
25+
removed: T[];
26+
source: SelectionModel<T>;
27+
}
28+
29+
export declare class SelectionModel<T> {
30+
changed: Subject<SelectionChange<T>>;
31+
onChange: Subject<SelectionChange<T>>;
32+
readonly selected: T[];
33+
constructor(_multiple?: boolean, initiallySelectedValues?: T[], _emitChanges?: boolean);
34+
clear(): void;
35+
deselect(...values: T[]): void;
36+
hasValue(): boolean;
37+
isEmpty(): boolean;
38+
isMultipleSelection(): boolean;
39+
isSelected(value: T): boolean;
40+
select(...values: T[]): void;
41+
sort(predicate?: (a: T, b: T) => number): void;
42+
toggle(value: T): void;
43+
}
44+
45+
export interface TreeDataNodeFlattener<T> {
46+
expandFlattenedNodes(nodes: T[], expansionModel: SelectionModel<T>): T[];
47+
flattenNodes(structuredData: any[]): T[];
48+
nodeDescendents(node: T, nodes: T[], onlyExpandable: boolean): void;
49+
}
50+
51+
export declare class UniqueSelectionDispatcher implements OnDestroy {
52+
listen(listener: UniqueSelectionDispatcherListener): () => void;
53+
ngOnDestroy(): void;
54+
notify(id: string, name: string): void;
55+
}
56+
57+
export declare type UniqueSelectionDispatcherListener = (id: string, name: string) => void;

0 commit comments

Comments
 (0)