I'm trying to use this external javascript library CamanJS with my Ionic2 (typescript project)
I've found several articles like this and this, however all of them assumes the library that is going to use is in typings
But CamanJS is not yet in the typings and there is a open ticket for it
my question is, is there a way to add an external js library (which is not yet added to typings) to an ionic2 (typescript) project?
Let me describe this process in a common case:
To include a JavaScript library in your TypeScript application you must first include it in your HTML file as a script tag.
<script src="js/your_external_library.js"></script>
To use the library you must add the following to one of your ts
files:
declare var libraryVar: any;
Replace libraryVar
with a variable, function, or class within your JavaScript library.
At this point it is ready for use.
After these steps you can use your external library with API which it provides. For example:
this.libraryVar = new libraryVar(parameters);
Call tsc
and .ts
file compiled into .js
with properly syntax and with your external library.