Skip to content

Commit 13bbc4f

Browse files
committed
chore: improve type safety in breakpoint observer
* Fixes a workaround where we cast the MediaQueryList event listener to any because TypeScript didn't have proper types before TS 3.1.
1 parent f951bf4 commit 13bbc4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cdk/layout/breakpoints-observer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ export class BreakpointObserver implements OnDestroy {
103103
const mql = this._mediaMatcher.matchMedia(query);
104104

105105
// Create callback for match changes and add it is as a listener.
106-
const queryObservable = new Observable((observer: Observer<MediaQueryList>) => {
106+
const queryObservable = new Observable((observer: Observer<MediaQueryListEvent>) => {
107107
// Listener callback methods are wrapped to be placed back in ngZone. Callbacks must be placed
108108
// back into the zone because matchMedia is only included in Zone.js by loading the
109109
// webapis-media-query.js file alongside the zone.js file. Additionally, some browsers do not
110110
// have MediaQueryList inherit from EventTarget, which causes inconsistencies in how Zone.js
111111
// patches it.
112-
const handler = (e: any) => this._zone.run(() => observer.next(e));
112+
const handler = (e: MediaQueryListEvent): void => this._zone.run(() => observer.next(e));
113113
mql.addListener(handler);
114114

115115
return () => {

0 commit comments

Comments
 (0)