Currently, I am in the process of determining which interfaces to include within the generics section of the open
function found in Angular's CDK Dialog. It is important to note that this is not related to Angular Material.
Here is what I have been able to deduce so far:
const dialogRef = this.dialog.open<IResult, unknown, IInputData>(FooComponent, {
width: '350px',
data: { x: 10 } as IInputData
})
dialogRef.closed.subscribe((data: IResult) => { ... }
As you can see, I have identified the first and last generics. However, the middle generic still remains unclear. Despite the lack of information regarding generics in the official documentation, I examined the interface of the open
function which is outlined here:
open<R = unknown, D = unknown, C = unknown>(component: ComponentType<C>, config?: DialogConfig<D, DialogRef<R, C>>): DialogRef<R, C>;
open<R = unknown, D = unknown, C = unknown>(template: TemplateRef<C>, config?: DialogConfig<D, DialogRef<R, C>>): DialogRef<R, C>;
open<R = unknown, D = unknown, C = unknown>(componentOrTemplateRef: ComponentType<C> | TemplateRef<C>, config?: DialogConfig<D, DialogRef<R, C>>): DialogRef<R, C>;
Specifically, I am interested in the generic D
, which is used within the DialogConfig
structure presented below:
/** Configuration for opening a modal dialog. */
export declare class DialogConfig<D = unknown, R = unknown, C extends BasePortalOutlet = BasePortalOutlet> {
...
/**
* Providers that will be exposed to the contents of the dialog. Can also
* be provided as a function in order to generate the providers lazily.
*/
providers?: StaticProvider[] | ((dialogRef: R, config: DialogConfig<D, R, C>, container: C) => StaticProvider[]);
/**
* Component into which the dialog content will be rendered. Defaults to `CdkDialogContainer`.
* A configuration object can be passed in to customize the providers that will be exposed
* to the dialog container.
*/
container?: Type<C> | {
type: Type<C>;
providers: (config: DialogConfig<D, R, C>) => StaticProvider[];
};
...
This is where my confusion arises. Any insights or suggestions on what D
might represent?