0

Using meteor I add jquery and three.js through meteor packages. And a simple javascript file runs to produce the spinning cube example.

Now I change my file.js to file.ts and it Errors: can't find the $jquery or THREE.

Basically the question is what do I have to do to include libraries through meteor so I can use typescript?

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
Dylan Froment
  • 63
  • 1
  • 7
  • With typescript you do not have an implicit global namespace anymore. You need to either [export](http://stackoverflow.com/questions/15760462/why-does-typescript-use-the-keyword-export-to-make-classes-and-interfaces-publ) or [import](http://stackoverflow.com/questions/12763684/how-to-require-jquery-via-amd-in-typescript) libs you want to use. [This might be relevant too](http://blog.dataflows.io/technology/2015/04/29/meteor_typescript.html) – Flavien Volken Sep 06 '15 at 15:08
  • I've looked at this... but it seems the problem is that when I change from js to ts that it tries to run the code before it loads the libraries. – Dylan Froment Sep 06 '15 at 15:18
  • There must be hundreds of people using these libraries with meteor I think I'm missing something really basic. – Dylan Froment Sep 06 '15 at 15:22
  • Could this simply be a matter of your [project structure for loading the js files ?](http://stackoverflow.com/questions/10109176/ordering-of-the-css-and-js-files-loaded-by-meteor) In short they are loaded (from first to last): Files within a "lib" named folder, the longest (deepest) path, then by alphabetical order. [more here](http://docs.meteor.com/#/full/structuringyourapp) – Flavien Volken Sep 06 '15 at 18:41
  • Using meteor, the libraries are kept in a packages folder; That's ok, it must be at the point of compilation; from TS to JS that it wants to know about the included libraries.... It's not mission critical to my project so I'm going to seperate my typescript stuff into a file with no dependancies, untill I find the way. – Dylan Froment Sep 06 '15 at 20:12

1 Answers1

0

This should work: https://atmospherejs.com/meteortypescript/compiler

'TypeScript is supported on both the client and the server. Files ending with .ts are automatically compiled to JavaScript by this meteor plugin.'

Kamal
  • 383
  • 1
  • 6
  • 16
  • I've looked at this... but it seems the problem is that when I change from js to ts that it tries to run the code before it loads the libraries. – Dylan Froment Sep 06 '15 at 15:18