2

i have a jQuery plugin .js file, and a Typescript file in which i want to use the first plugin. after googling that, maybe i need import library.d.ts into my typescript file like following code, and how about that plugin(slof-slider.js)?

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

2 Answers 2

6

After you have added the following line :

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

You need to tell TypeScript about the functions added by SlofSlider (not sure about the name?) e.g. if you want :

$('div').slider(); 

to compile you would do something like:

interface JQuery {
    slider: Function;
}
Sign up to request clarification or add additional context in comments.

2 Comments

should i download jquery.d.ts file and reside it under a certain directory?im confused, cuz i can not find this file online. thanks basarat.
@paulcheung you can download this file from DefinitelyTyped : github.com/borisyankov/DefinitelyTyped/tree/master/jquery You can it anywhere, but you will need to adjust the relative path accordingly. Simplest case is to paste it in the same folder : github.com/borisyankov/DefinitelyTyped/blob/master/jquery/…
1

After adding this reference

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

Add the jquery.min library to webpage... that should work fine..

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.