Skip to content

Commit d4f8440

Browse files
committed
fix(multiple): use cross-compatible type for setTimeout
Fixes that some places were raising an error due to the return type of `setTimeout` being different between the browser and Node.
1 parent db740bd commit d4f8440

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

src/cdk/a11y/focus-monitor/focus-monitor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ export class FocusMonitor implements OnDestroy {
9898
private _windowFocused = false;
9999

100100
/** The timeout id of the window focus timeout. */
101-
private _windowFocusTimeoutId: number;
101+
private _windowFocusTimeoutId: ReturnType<typeof setTimeout>;
102102

103103
/** The timeout id of the origin clearing timeout. */
104-
private _originTimeoutId: number;
104+
private _originTimeoutId: ReturnType<typeof setTimeout>;
105105

106106
/**
107107
* Whether the origin was determined via a touch interaction. Necessary as properly attributing
@@ -137,7 +137,7 @@ export class FocusMonitor implements OnDestroy {
137137
// Make a note of when the window regains focus, so we can
138138
// restore the origin info for the focused element.
139139
this._windowFocused = true;
140-
this._windowFocusTimeoutId = window.setTimeout(() => (this._windowFocused = false));
140+
this._windowFocusTimeoutId = setTimeout(() => (this._windowFocused = false));
141141
};
142142

143143
/** Used to reference correct document/window */

src/cdk/a11y/live-announcer/live-announcer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class LiveAnnouncer implements OnDestroy {
2828

2929
private _liveElement: HTMLElement;
3030
private _document = inject(DOCUMENT);
31-
private _previousTimeout: number;
31+
private _previousTimeout: ReturnType<typeof setTimeout>;
3232
private _currentPromise: Promise<void> | undefined;
3333
private _currentResolve: (() => void) | undefined;
3434

src/material/bottom-sheet/bottom-sheet-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class MatBottomSheetRef<T = any, R = any> {
4747
private _result: R | undefined;
4848

4949
/** Handle to the timeout that's running as a fallback in case the exit animation doesn't fire. */
50-
private _closeFallbackTimeout: number;
50+
private _closeFallbackTimeout: ReturnType<typeof setTimeout>;
5151

5252
constructor(
5353
private _ref: DialogRef<R, T>,

src/material/dialog/dialog-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class MatDialogRef<T, R = any> {
5252
private _result: R | undefined;
5353

5454
/** Handle to the timeout that's running as a fallback in case the exit animation doesn't fire. */
55-
private _closeFallbackTimeout: number;
55+
private _closeFallbackTimeout: ReturnType<typeof setTimeout>;
5656

5757
/** Current state of the dialog. */
5858
private _state = MatDialogState.OPEN;

src/material/snack-bar/snack-bar-container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy
7373
private readonly _announceDelay: number = 150;
7474

7575
/** The timeout for announcing the snack bar's content. */
76-
private _announceTimeoutId: number;
76+
private _announceTimeoutId: ReturnType<typeof setTimeout>;
7777

7878
/** Whether the component has been destroyed. */
7979
private _destroyed = false;

src/material/snack-bar/snack-bar-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class MatSnackBarRef<T> {
4545
* Timeout ID for the duration setTimeout call. Used to clear the timeout if the snackbar is
4646
* dismissed before the duration passes.
4747
*/
48-
private _durationTimeoutId: number;
48+
private _durationTimeoutId: ReturnType<typeof setTimeout>;
4949

5050
/** Whether the snack bar was dismissed using the action button. */
5151
private _dismissedByAction = false;

0 commit comments

Comments
 (0)