October 03, 2012

How to install typescript on mac os x

typescript

This article explains how to install TypeScript on Mac OS X easily.

The following steps are tested on OS X Mountain Lion 10.8.2

1. install Homebrew:

$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

2. Install nodejs using home-brew:

$ brew install nodejs

3. get and install npm:

$ curl https://npmjs.org/install.sh | sh

4. get TypeScript:

$ npm install -g typescript

## 5. Test TypeScript:

In your editor, type the following JavaScript code in greeter.ts:

function greeter(person) {
  return "Hello, " + person;
}    
var user = "Jane User";   
document.body.innerHTML = greeter(user);

6. Compile the code:

At the command line, run the TypeScript compiler:

$ tsc greeter.ts

The result will be a file greeter.js which contains the same JavaScript that you fed in.