Skip to content

Commit a1c6b56

Browse files
committed
chore(dialog): add generic param for config data
Adds a generic parameter to the `MatDialogConfig` that indicates the type of its `data`. Fixes #4398.
1 parent 3c6f7a2 commit a1c6b56

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib/dialog/dialog-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface DialogPosition {
2323
/**
2424
* Configuration for opening a modal dialog with the MatDialog service.
2525
*/
26-
export class MatDialogConfig {
26+
export class MatDialogConfig<D = any> {
2727

2828
/**
2929
* Where the attached component should live in Angular's *logical* component tree.
@@ -61,7 +61,7 @@ export class MatDialogConfig {
6161
position?: DialogPosition;
6262

6363
/** Data being injected into the child component. */
64-
data?: any = null;
64+
data?: D | null = null;
6565

6666
/** Layout direction for the dialog's content. */
6767
direction?: Direction = 'ltr';

src/lib/dialog/dialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ export class MatDialog {
114114
* @param config Extra configuration options.
115115
* @returns Reference to the newly-opened dialog.
116116
*/
117-
open<T>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
118-
config?: MatDialogConfig): MatDialogRef<T> {
117+
open<T, D = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
118+
config?: MatDialogConfig<D>): MatDialogRef<T> {
119119

120120
const inProgressDialog = this.openDialogs.find(dialog => dialog._isAnimating());
121121

0 commit comments

Comments
 (0)