Getting The Right Set Up For TypeScript
This is actually quite a rework of my original ideas, because I have worked with TypeScript for a long time now and can happily add the benefit of hindsight to my view of what makes a great TypeScript set up. This isn’t the one true way, but I have found that the following set up rocks the TypeScript…
So what is a good TypeScript set up…
Firstly, I am using Visual Studio 2013 – but you can get a really good experience with Web Storm too. The IDE shouldn’t make any difference to the set up I’m using. I’m not using any particular special plugins for TypeScript coolness.
The more I use TypeScript, the more I see value in external modules. My original method was internal modules for small stuff, external modules for big stuff. The thing is though, at some point your small stuff will turn into big stuff. Plus you have to make a call about how big stuff is going to get. You also have to use external modules to be effective when running on the server, so you then have to take this into account too.
This is all actually pointless and I recommend external modules for everything.
What if I want to flatten everything into a single file – do I have to use internal modules for this?
Nope. You can use the RequireJS opimiser to flatten your external modules into a single file. It will also minify them using Uglify, potentially compressing your workflow and giving you more time to do push-ups or something.
Can I run my app everywhere if I use external modules?
Yes. That’s one of the key benefits. You compile it with –module commonjs for NodeJS and –module amd for use with RequireJS or to run it through the RequireJS optimiser.