Skip to content

Commit

Permalink
have to explicitly cast some things
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Osman committed Nov 20, 2017
1 parent 35173c1 commit 2c7d4fd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/modules/init/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const initButtons = (buttons: ButtonList, dangerMode: boolean): void => {
const footerEl: Element = injectElIntoModal(footerMarkup);

for (let key in buttons) {
const buttonOpts: ButtonOptions = buttons[key];
const buttonOpts: ButtonOptions = buttons[key] as ButtonOptions;
const buttonEl: Node = getButton(key, buttonOpts, dangerMode);

if (buttonOpts.visible) {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/init/modal.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ButtonList } from './../options/buttons';
import { stringToNode, getNode } from '../utils';
import { modalMarkup } from '../markup';
import { SwalOptions } from '../options';
Expand Down Expand Up @@ -54,7 +55,7 @@ export const initModalContent = (opts: SwalOptions): void => {
initTitle(opts.title);
initText(opts.text);
initContent(opts.content);
initButtons(opts.buttons, opts.dangerMode);
initButtons(opts.buttons as ButtonList, opts.dangerMode);
};

const initModalOnce = (): void => {
Expand Down
12 changes: 6 additions & 6 deletions typings/modules/options/buttons.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export interface ButtonOptions {
visible: boolean;
text: string;
value: any;
className: string;
closeModal: boolean;
visible?: boolean;
text?: string;
value?: any;
className?: string;
closeModal?: boolean;
}
export interface ButtonList {
[buttonNamespace: string]: ButtonOptions;
[buttonNamespace: string]: ButtonOptions | boolean;
}
export declare const CONFIRM_KEY = "confirm";
export declare const CANCEL_KEY = "cancel";
Expand Down
2 changes: 1 addition & 1 deletion typings/modules/options/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface SwalOptions {
title: string;
text: string;
icon: string;
buttons: ButtonList;
buttons: ButtonList | Array<string | boolean>;
content: ContentOptions;
className: string;
closeOnClickOutside: boolean;
Expand Down

0 comments on commit 2c7d4fd

Please sign in to comment.