Naveen Naveen - 2 months ago 6
TypeScript Question

Skylinkjs with Typescript

A typescript amateur here. I am trying to use SkylinkJS with typescript language. What is the standard way of using npm library with TypeScript.

The link to Skylinkjs npm module is https://github.com/Temasys/SkylinkJS

Answer

I would do it in the following steps:

  1. Install npm package (skylinkjs)
  2. Locate and install definitions (d.ts files) for skylinkjs. Here might be a problem as it does not look like they are available. If so - you can work with skylink as you would in pure javascript using ambient declarations, for example:
declare var Skylink;
var Demo = Demo || {};
Demo.Skylink = new Skylink();
//...

Or create your own type definitions skylink to leverage the typescript types checking etc. More info here: link

  1. Have fun writing your app with typescript.
  2. After you are done with #3 - compile your ts files into JS using tsc compiler or (if you are using gulp/grunt) - corresponding plugins.
  3. Reference your compiled JS files in html page or use some module loader (SystemJS) to load them dynamically. Use hero app at angular.io as a sample.
  4. Optionally you can bundle your app into neat small package with bundling tools like webpack or systemjs builder.
Comments