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
| $ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
|
2. Install nodejs using home-brew:
3. get and install npm:
1
| $ curl https://npmjs.org/install.sh | sh
|
4. get TypeScript:
1
| $ npm install -g typescript
|
5. Test TypeScript:
In your editor, type the following JavaScript code in greeter.ts:
1
2
3
4
5
| 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:
The result will be a file greeter.js which contains the same JavaScript that you fed in.