How to import non-typescript javascript libraries into ionic

i want to import velocity-animate library into ionic which doesn’t have a d.ts file. Its a pure js library. how can i import and implement such kind of js files into ionic 2. I tried below steps

npm install velocity-animate

which download and save velocity.js file into npm modules. whats next?

the typescript guys maintain a vast number of type definitions for a wide array of javascript libraries. you can install these by doing:

npm install @typings/velocity-animate --save

then I think it’s just a case of import Velocity from 'velocity-animate'

It doesnt help :frowning: Can you pleasae tell me what is ‘Velocity’ and what is ‘Velocity animate’ here and where can i find them in index.dts or package.json of modules?

Velocity is the name of the module, and velocity-animate is the package it’s from in your node_modules folder. they will not be in the package.json file because the type definitions are a package from @types/velocity-animate. think of import Velocity from 'velocity-animate'; being like var Velocity = require('velocity-animate');

the type definitions may not work because the type definitions are outdated, and looks like it requires jquery, but no matter, the module you npm installed will still work.

in the declarations.d.ts file you should have declare module '*'; which means you can reference any JS module without typescript giving errors.

where is the declarations.d.ts file?

within your text editor, you should be able to do ctrl-p and type the file
to find it within your project if you already have one. if not, look at the
typescript documentation