Search code examples
javascriptmeteortypescriptnpmangular2-meteor

Using non-typescript npm package (pondjs) with Meteor from typescript files


I added the Pondjs library to my project with:

meteor npm install --save pondjs

But I can't figure out how to use it within my Typescript files,

The documentation says:

To use it within a browser you will need to install it with npm and then build your source with Webpack, Browserify or something similar.

But since I am using (Angular2-)Meteor I can't use Webpack or Browserify.

I tried importing as:

import 'pondjs'; // no complaint about import

declare var Index: any;
let index = new Index("1d-12345"); //but: Can't find variable: Index

Also:

import * as something from 'pondjs'; // cannot find module 'pondjs'

Solution

  • Turns out the the typescript compiler cannot find the module because there are no typings. However the package can still be used with ES6 imports:

    import {Index, TimeSeries} from "pondjs";
    

    Meteor will find the package and send it to the browser. So just ignore the compiler error or write typings.