Skip to content

Commit b29ac45

Browse files
crisbetoandrewseguin
authored andcommitted
chore(dialog): add generic param for config data (#7447)
Adds a generic parameter to the `MatDialogConfig` that indicates the type of its `data`. BREAKING CHANGE: Material now requires at least TypeScript 2.4. Fixes #4398.
1 parent b6f7f17 commit b29ac45

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib/dialog/dialog-config.ts

+2-2
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.
@@ -73,7 +73,7 @@ export class MatDialogConfig {
7373
position?: DialogPosition;
7474

7575
/** Data being injected into the child component. */
76-
data?: any = null;
76+
data?: D | null = null;
7777

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

src/lib/dialog/dialog.ts

+2-2
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)