@@ -63,7 +63,7 @@ export class MatSnackBar implements OnDestroy {
63
63
* If there is a parent snack-bar service, all operations should delegate to that parent
64
64
* via `_openedSnackBarRef`.
65
65
*/
66
- private _snackBarRefAtThisLevel : MatSnackBarRef < any > | null = null ;
66
+ private _snackBarRefAtThisLevel : MatSnackBarRef < unknown > | null = null ;
67
67
68
68
/** The component that should be rendered as the snack bar's simple component. */
69
69
simpleSnackBarComponent = SimpleSnackBar ;
@@ -75,12 +75,12 @@ export class MatSnackBar implements OnDestroy {
75
75
handsetCssClass = 'mat-mdc-snack-bar-handset' ;
76
76
77
77
/** Reference to the currently opened snackbar at *any* level. */
78
- get _openedSnackBarRef ( ) : MatSnackBarRef < any > | null {
78
+ get _openedSnackBarRef ( ) : MatSnackBarRef < unknown > | null {
79
79
const parent = this . _parentSnackBar ;
80
80
return parent ? parent . _openedSnackBarRef : this . _snackBarRefAtThisLevel ;
81
81
}
82
82
83
- set _openedSnackBarRef ( value : MatSnackBarRef < any > | null ) {
83
+ set _openedSnackBarRef ( value : MatSnackBarRef < unknown > | null ) {
84
84
if ( this . _parentSnackBar ) {
85
85
this . _parentSnackBar . _openedSnackBarRef = value ;
86
86
} else {
@@ -98,11 +98,11 @@ export class MatSnackBar implements OnDestroy {
98
98
* @param component Component to be instantiated.
99
99
* @param config Extra configuration for the snack bar.
100
100
*/
101
- openFromComponent < T , D = any > (
101
+ openFromComponent < T , D = unknown > (
102
102
component : ComponentType < T > ,
103
103
config ?: MatSnackBarConfig < D > ,
104
104
) : MatSnackBarRef < T > {
105
- return this . _attach ( component , config ) as MatSnackBarRef < T > ;
105
+ return this . _attach ( component , config ) ;
106
106
}
107
107
108
108
/**
@@ -113,9 +113,9 @@ export class MatSnackBar implements OnDestroy {
113
113
* @param config Extra configuration for the snack bar.
114
114
*/
115
115
openFromTemplate (
116
- template : TemplateRef < any > ,
116
+ template : TemplateRef < unknown > ,
117
117
config ?: MatSnackBarConfig ,
118
- ) : MatSnackBarRef < EmbeddedViewRef < any > > {
118
+ ) : MatSnackBarRef < EmbeddedViewRef < unknown > > {
119
119
return this . _attach ( template , config ) ;
120
120
}
121
121
@@ -187,14 +187,19 @@ export class MatSnackBar implements OnDestroy {
187
187
/**
188
188
* Places a new component or a template as the content of the snack bar container.
189
189
*/
190
+ private _attach < T > ( content : ComponentType < T > , userConfig ?: MatSnackBarConfig ) : MatSnackBarRef < T > ;
191
+ private _attach < T > (
192
+ content : TemplateRef < T > ,
193
+ userConfig ?: MatSnackBarConfig ,
194
+ ) : MatSnackBarRef < EmbeddedViewRef < T > > ;
190
195
private _attach < T > (
191
196
content : ComponentType < T > | TemplateRef < T > ,
192
197
userConfig ?: MatSnackBarConfig ,
193
- ) : MatSnackBarRef < T | EmbeddedViewRef < any > > {
198
+ ) : MatSnackBarRef < T | EmbeddedViewRef < unknown > > {
194
199
const config = { ...new MatSnackBarConfig ( ) , ...this . _defaultConfig , ...userConfig } ;
195
200
const overlayRef = this . _createOverlay ( config ) ;
196
201
const container = this . _attachSnackBarContainer ( overlayRef , config ) ;
197
- const snackBarRef = new MatSnackBarRef < T | EmbeddedViewRef < any > > ( container , overlayRef ) ;
202
+ const snackBarRef = new MatSnackBarRef < T | EmbeddedViewRef < unknown > > ( container , overlayRef ) ;
198
203
199
204
if ( content instanceof TemplateRef ) {
200
205
const portal = new TemplatePortal ( content , null ! , {
@@ -231,11 +236,11 @@ export class MatSnackBar implements OnDestroy {
231
236
232
237
this . _animateSnackBar ( snackBarRef , config ) ;
233
238
this . _openedSnackBarRef = snackBarRef ;
234
- return this . _openedSnackBarRef ;
239
+ return snackBarRef ;
235
240
}
236
241
237
242
/** Animates the old snack bar out and the new one in. */
238
- private _animateSnackBar ( snackBarRef : MatSnackBarRef < any > , config : MatSnackBarConfig ) {
243
+ private _animateSnackBar ( snackBarRef : MatSnackBarRef < unknown > , config : MatSnackBarConfig ) {
239
244
// When the snackbar is dismissed, clear the reference to it.
240
245
snackBarRef . afterDismissed ( ) . subscribe ( ( ) => {
241
246
// Clear the snackbar ref if it hasn't already been replaced by a newer snackbar.
0 commit comments