Typescript: How to reference jquery-easyui library? -


i'm new typescript. trying work jquery-easyui library not have d.ts definition file in defintelytyped repo. not have time (or skills) write d.ts file library. how go using in typescript file?

in test.ts file, tried doing a:

/// <amd-dependency path="libs/easyui/jquery.easyui.min.js"> function newuser(){     $('#dlg').dialog('open').dialog('settitle','new user');     ... etc.  

but webstorm reports error on "$" symbol "unresolved method or function $()". tried replacing amd-dependency .. reference.. still did not work. library path correct. code works fine if put in .js file.

step 1 include declare file jquery. @ least type info vanilla jquery. put following @ top of js files using jquery

/// <reference path='jquery.d.ts' /> 

next want create file jquery.easyui.d.ts , add this:

interface jquery {     dialog: any; } 

the code above means jquery interface (initially defined in jquery.d.ts) has member called dialog, , can of type (in case it's function). since use any, you're not getting type it, @ least compile. don't know easyui adds jquery, need add of new methods interface.

and finally, add <reference> comment below first 1 jquery.easyui.d.ts. time compiler complains not being defined easyui, add jquery.easyui.d.ts file.

once more proficient syntax, can flesh out types in jquery.easyui.d.ts file , contribute them definitelytyped project!


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -