I'm trying to migrate some js code to typescript. Specifically I'm having trouble with AlertifyJs. Now Alertify seems to be many things.
Now I can find the d.ts for (1) on DefinitelyTyped, but none for the others. I want to use (3)!
I would like to somehow wrap or call directly alertify.confirm("you go", "girl"); from ts.
How can I achieve this?
Thanks
PS: Coding in vs2015
EDIT: Thought I'd provide you beutiful nerds with a code snippet of what I got somefar
///<reference path="../typings/jquery/jquery.d.ts"/>
///<reference path="../typings/toastr/toastr.d.ts"/>
module mymodule.Web {
export class CommonTools {
constructor() {
toastr.options.closeButton = false;
}
showInfo(title: string, message: string) {
toastr.info(message, title);
}
showConfirm(title: string, message: string) {
//**code goes here**
}
}
}
The simplest (and least safe or elegant) solution could be to add this somewhere in the global scope in your typescript.
declare var alertify: any;
Like this, typescript will know about the alertify
variable.
If you are more precise, you can introduce your own (for example) AlertifyJSStatic
interface with those methods you want to use, and give that as type of alertify
variable.
interface AlertifyJSStatic {
confirm(a: string, b:string);
}
declare var alertify: AlertifyJSStatic;
Sometimes it's easier to add your own needs quickly than get lost in d.ts
libraries (and versions).