typescript - How to use 'new' for jQuery.Event() -


using existing definitelytyped jquery.d.ts declarations, not able this:

/// <reference path="../scripts/typings/jquery/jquery.d.ts" /> declare var firstevent; var newevent = new jquery.event(firstevent); 

but generates compiler error:

testing.ts(3,19): new expression valid on constructors 

and according jquery.d.ts, makes sense because jquery.event defined function not type.

i can force cast any:

/// <reference path="../scripts/typings/jquery/jquery.d.ts" /> declare var firstevent; var newevent = new <any>jquery.event(firstevent); 

but sledgehammer feels wrong.

is limitation of typescript declarations or limitation in definition of jquery.d.ts?

this shortcoming in jquery definition file. can represent callable-or-newable thing (written here using explicit interfaces clarity; use type literal well):

interface callableornewable {     (arg: string);     new (arg: string); }  interface thing {     event: callableornewable; }  var x: thing; new x.event(''); // ok x.event(''); // ok 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -