Using Typescript

I recently started using Typescript, and think it’s a great addition to the JS ecosystem.
With Microsoft and now also Google behind it, I think the language is looking at a promising future.

I personally used to prefer strongly typed or even static languages in the backend, and am always quite concerned about having JS not only on the client, but on the server. Of course we can and should test extensively, but I see great value in Typescript.

Is anyone using Typescript extensively in their Meteor projects?
How do you do it? (compiler package)
What are your thoughts on this?

1 Like

I have tried it a little bit, but found it not adapted to the “all code in packages” approach i use with meteor.
Typescript use his own “require” way, which is not compatible with the one used by meteor.
You end up writing a lot of tedious manuaf references to your definitions for the typing to work.
I replaced it with JSDoc/Google closure compiler type notation which is written in comments and doesn’t temper with your code which is still vanilla JS.
The type is then continuously checked by webstorm during typing and gives great (albeit not 100%) types autocompletion/ validation.

I also tend to agree about the importance of static typing, as most of my (relatively) big app bugs are somewhat type/schema related.

Hey,
I’m looking at TypeScript with Meteor too. Have you looked at compiling all definition files into one which you can then manually reference for each package.
Something like if you have following packages

comments
users```
You can have `blogs.d.ts` which is compilation of all definitions for package exposed from blogs package. Then from comments package you could just do `/// <reference path='blogs.d.ts' />` to reference blogs package types. 
Am I missing something? It does work in our small nodejs app.

Hi guys!

Feel free to take a look at our blog post about using Meteor with TypeScript: http://blog.dataflows.io/technology/2015/04/29/meteor_typescript.html

3 Likes

I used typescript for a node project recently, and had a fantastic experience. it’s so great for refactoring to know all your method signatures are being checked. but the notes above make it sound quite daunting to use with meteor.

I wonder if Facebook’s Flow project could be integrated in any way?

If you use webstorm, the IDE do it for you, pretty much you only have to install meteor, then install https://github.com/meteor-typescript/meteor-typescript-libs the libs, and you are ready to go. Meteor + Typescript + Webstorm solution.

2 Likes

Just to keep it updated - the main Typescript package for Meteor is this one - https://github.com/barbatus/typescript

1 Like

@Urigo, I’m new to Meteor and I’d like to use Typescript and found this thread. I’m just double checking that the package from @barbatus is still the main Typescript package for Meteor?

Thanks in advance.

Yes, that’s the main one and should work great and be updated to the latest Typescript.
Feel free to open issues in case you see something different

1 Like