How to install typescript on mac os x

less than 1 minute read


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"

2. Install nodejs using home-brew:

$ brew install nodejs

3. get and install npm:

$ curl | 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.

Leave a comment