2014-02-10 2 views
0

Я пытаюсь использовать пользователя Пользовательский диалог с bootbox.d.ts. Он не компилируется.bootbox.dialog ошибка компиляции в TypeScript

bootbox.dialog({ 
    message: "I am a custom dialog", 
    buttons: { 
    success: { 
     label: "Success!", 
     className: "btn-success", 
     callback: function() { 
     Example.show("great success"); 
     } 
    }, 
    danger: { 
     label: "Danger!", 
     className: "btn-danger", 
     callback: function() { 
     Example.show("uh oh, look out!"); 
     } 
    }, 
    main: { 
     label: "Click ME!", 
     className: "btn-primary", 
     callback: function() { 
     Example.show("Primary button"); 
     } 
    } 
    } 
}); 

Ошибка:

Error 49 Supplied parameters do not match any signature of call target: Could not apply type 'string' to argument 1 which is of type '{ message: string; buttons: { cancel: { label: string; className: string; }; confirmDelete: { label: string; className: string; callback:() => void; }; }; }'.

bootbox.d.ts:

interface BootboxStatic { 
    alert(message: string, callback:() => void): void; 
    alert(message: string, customButtonText?: string, callback?:() => void): void; 
    confirm(message: string, callback: (result: boolean) => void): void; 
    confirm(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: boolean) => void): void; 
    prompt(message: string, callback: (result: string) => void, defaultValue?: string): void; 
    prompt(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: string) => void, defaultValue?: string): void; 
    dialog(message: string, handlers: BootboxHandler[], options?: any): void; 
    dialog(message: string, handler: BootboxHandler): void; 
    dialog(message: string): void; 
    hideAll(): void; 
    animate(shouldAnimate: boolean): void; 
    backdrop(backdropValue: string): void; 
    classes(customCssClasses: string): void; 
    setIcons(icons: BootboxIcons): void; 
    setLocale(localeName: string): void; 
    addLocale(localeName: string, translations: BootboxLocale) : void; 
} 

Как я могу изменить определение принять диалог с параметром я использую?

ответ

0

Я его отсортировал. Пришлось добавить строку

dialog(options: any): void; // Had to add this line

в bootbox.d.ts:

interface BootboxStatic { 
    alert(message: string, callback:() => void): void; 
    alert(message: string, customButtonText?: string, callback?:() => void): void; 
    confirm(message: string, callback: (result: boolean) => void): void; 
    confirm(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: boolean) => void): void; 
    prompt(message: string, callback: (result: string) => void, defaultValue?: string): void; 
    prompt(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: string) => void, defaultValue?: string): void; 
    dialog(message: string, handlers: BootboxHandler[], options?: any): void; 
    dialog(message: string, handler: BootboxHandler): void; 
    dialog(message: string): void; 
    dialog(options: any): void; // Had to add this line 
    hideAll(): void; 
    animate(shouldAnimate: boolean): void; 
    backdrop(backdropValue: string): void; 
    classes(customCssClasses: string): void; 
    setIcons(icons: BootboxIcons): void; 
    setLocale(localeName: string): void; 
    addLocale(localeName: string, translations: BootboxLocale) : void; } 
0

я хотел бы использовать BootboxHandler массив

dialog(message: string, handlers: BootboxHandler[], options?: any): void; 

interface BootboxHandler { 
    label: string; 
    class: string; 
    callback: (result?: any) => void; 
} 

Изменить код для:

bootbox.dialog("I am a custom dialog", 
    [{ 
     label: "Success!", 
     class: "btn-success", 
     callback: function() { 
     Example.show("great success"); 
     } 
    }, 
    { 
     label: "Danger!", 
     class: "btn-danger", 
     callback: function() { 
     Example.show("uh oh, look out!"); 
     } 
    }, 
    { 
     label: "Click ME!", 
     class: "btn-primary", 
     callback: function() { 
     Example.show("Primary button"); 
     } 
    } 
    }] 
); 
Смежные вопросы