Use TypeScript with Coderunner 2

|

UPDATE 2016-10-14:
It's been brought to my attention on Twitter that this setup is not playing nicely with classes. Because I'm not doing front end web development so much anymore, I'm not going to fix it. If anyone can fix this, let me know and I'll happily update the post.

CodeRunner 2 is a great OS X utility to run snippets of code on-the-fly in just about any language.

Lately, I've been experimenting with Angular 2 and TypeScript. CodeRunner can't run TypeScript out-of-the-box, but it can be configured to run any language. Here's how:

  1. Make sure you have Node.js and TypeScript. If not:

    brew install node &&
    npm install -g typescript
  2. Go to CodeRunner's preferences. Under "Languages" tab create a new language and copy the following settings:
    !

  3. Click Edit Script (circled above) and replace the code in the window with:

    /usr/local/bin/tsc "$CR_FILENAME" --out $CR_TMPDIR/tmp.js
    echo "$CR_TMPDIR/tmp.js"
  4. In the "Templates Panel" add the following item:

And that's it. Happy TypeScripting!