Skip to content

Commit

Permalink
fix(material/snack-bar): update generic types for openFromComponent (#…
Browse files Browse the repository at this point in the history
…24634)

* fix(material/snack-bar): update generic types for openFromComponent

Add a generic for MatSnackBarConfig inside openFromComponent method

* fix(material/snack-bar): Update the generic from openFromComponent for public_api_guard
  • Loading branch information
GeorgianStan authored Apr 12, 2022
1 parent fa12442 commit 9243266
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/material/snack-bar/snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export abstract class _MatSnackBarBase implements OnDestroy {
* @param component Component to be instantiated.
* @param config Extra configuration for the snack bar.
*/
openFromComponent<T>(component: ComponentType<T>, config?: MatSnackBarConfig): MatSnackBarRef<T> {
openFromComponent<T, D = any>(
component: ComponentType<T>,
config?: MatSnackBarConfig<D>,
): MatSnackBarRef<T> {
return this._attach(component, config) as MatSnackBarRef<T>;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/snack-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export abstract class _MatSnackBarBase implements OnDestroy {
open(message: string, action?: string, config?: MatSnackBarConfig): MatSnackBarRef<TextOnlySnackBar>;
get _openedSnackBarRef(): MatSnackBarRef<any> | null;
set _openedSnackBarRef(value: MatSnackBarRef<any> | null);
openFromComponent<T>(component: ComponentType<T>, config?: MatSnackBarConfig): MatSnackBarRef<T>;
openFromComponent<T, D = any>(component: ComponentType<T>, config?: MatSnackBarConfig<D>): MatSnackBarRef<T>;
openFromTemplate(template: TemplateRef<any>, config?: MatSnackBarConfig): MatSnackBarRef<EmbeddedViewRef<any>>;
protected abstract simpleSnackBarComponent: Type<TextOnlySnackBar>;
protected abstract snackBarContainerComponent: Type<_SnackBarContainer>;
Expand Down

0 comments on commit 9243266

Please sign in to comment.