3

Possible Duplicate:
Using jQuery plugin in TypeScript

So I'm making a webApp with the typescript, I already made the webapp in JavaScript and now I want to do it in typescript,

in this webapp I need a few jQuery libraries like a standard jQuery and jQuerySVG, the jQuery.d.ts can be found easily and I can just reference it to the typescript, the problem is that jQuerySVG, I can't find the typescript version for jquery.svg.js (like jQuery.svg.d.ts)

so how can I work this out?

or will the typescript work if I just reference the jQuery.svg.js in the script tag on my html file?

0

1 Answer 1

5

You will need to generate this file yourself. Its fairly simple to document the functions that you are using in your code by writing the d.ts file.
Update: Looking at the svg documentation, you are looking for a jquery.svg.d.ts file that uses the JQuery selector:

// from documentation on svg:
//$(selector).svg(loadURL) 
//$(selector).svg(onLoad) 
//$(selector).svg('get') // Retrieve SVG wrapper 
//$(selector).svg('destroy') // Remove SVG functionality 

// this is what you need to put in your jquery.svg.d.ts
interface JQuery {
    svg(loadUrl: string): JQuery;
    svg(x: Function): JQuery;
}

Then you will be able to write statements like this:

$('selector').svg('testLoadUrl');

$('selector').svg(() => {
    // function call
});

$('selector').svg('get');  
Sign up to request clarification or add additional context in comments.

2 Comments

how can I generate the d.ts file exactly (for the JQuery.svg library)?
by hand or search for one. no tools generate it for you from plain js

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.