Skip to content

Commit

Permalink
fix(types): support for generic types in interfaces and methods (#1981)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelss95 committed May 28, 2020
1 parent 22a06e5 commit 146309c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sweetalert2.d.ts
Expand Up @@ -21,7 +21,7 @@ declare module 'sweetalert2' {
* Swal.fire('The Internet?', 'That thing is still around?', 'question');
* ```
*/
function fire(title?: string, html?: string, icon?: SweetAlertIcon): Promise<SweetAlertResult>;
function fire<T>(title?: string, html?: string, icon?: SweetAlertIcon): Promise<SweetAlertResult<T>>;

/**
* Function to display a SweetAlert2 popup, with an object of options, all being optional.
Expand All @@ -36,7 +36,7 @@ declare module 'sweetalert2' {
* })
* ```
*/
function fire(options: SweetAlertOptions): Promise<SweetAlertResult>;
function fire<T>(options: SweetAlertOptions): Promise<SweetAlertResult<T>>;

/**
* Reuse configuration by creating a `Swal` instance.
Expand Down Expand Up @@ -80,7 +80,7 @@ declare module 'sweetalert2' {
* @param result The promise originally returned by `Swal.fire()` will be resolved with this value.
* If no object is given, the promise is resolved with an empty `SweetAlertResult` object.
*/
function close(result?: SweetAlertResult): void;
function close<T>(result?: SweetAlertResult<T>): void;

/**
* Gets the popup.
Expand Down Expand Up @@ -350,8 +350,8 @@ declare module 'sweetalert2' {

export type SweetAlertGrow = 'row' | 'column' | 'fullscreen' | false;

export interface SweetAlertResult {
value?: any;
export interface SweetAlertResult<T = any> {
value?: T;
dismiss?: Swal.DismissReason;
isConfirmed: boolean;
isDismissed: boolean;
Expand Down

0 comments on commit 146309c

Please sign in to comment.