From e1a2b80c6774cf1d2aa5c402d782b60e6f260ea3 Mon Sep 17 00:00:00 2001 From: Morgan Touverey Quilling Date: Mon, 5 Mar 2018 23:42:40 +0100 Subject: [PATCH] feat(SwalComponent): fix compatibility with SweetAlert2 ^7.12.4 type definitions --- src/swal.component.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/swal.component.ts b/src/swal.component.ts index e9544da..98e0fb7 100644 --- a/src/swal.component.ts +++ b/src/swal.component.ts @@ -209,10 +209,12 @@ export class SwalComponent implements OnChanges, OnDestroy { const promise = swal(options); //=> Handle (confirm) and (cancel) @Outputs + // tslint:disable-next-line:no-string-literal + const useRejections = (options as { useRejections?: boolean }).useRejections; + promise.then( result => { - // noinspection JSDeprecatedSymbols - support for old SweetAlert2 versions - if (options.useRejections) { + if (useRejections) { this.confirm.emit(result); } else if ('value' in result) { this.confirm.emit(result.value); @@ -221,8 +223,7 @@ export class SwalComponent implements OnChanges, OnDestroy { } }, err => { - // noinspection JSDeprecatedSymbols - support for old SweetAlert2 versions - if (options.useRejections) { + if (useRejections) { this.cancel.emit(err); } }