Im new to typescript and im trying to get the a hang on the concept of how modules/packages works in typescript..
I am currently in the need of using slick-carousel to create a simple image slider.
However.. I have managed to install jquery.. but I dont quite get how to get slick to work with typescript.
So far I have used npm typings to install my packages.
So I just ran typings install slick-carousel
.. and the definition-file showed up fine..
however.. the definition-file contains no declaration only interfaces..
So I cant really "import" slick-carousel into the file where I need to use it (I might be wrong).. so I guess that the package is supposed to extend the already existing jquery import in some why..
However.. If I do this:
import * as $ from 'jquery';
class Splash {
init() {
$.slick();
}
}
then
$.slick();
cant be resolved..
so.. how do you "import" a package that only extends a pre-existing package like jquery?
Thanks in advance!
Using an AMD module loader (example RequireJS) would ensure your code only runs once all external modules, and their dependencies, have been loaded.
Here is an example using RequireJS with a shim config:
index.html
app.js (after compiled from app.ts)
The RequireJS documentation has a whole section on how to use with jQuery