Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does TypeScript need Node.js?

This is probably not the best question but I'm still completely new to JS. I'm interested in Typescript (being an AS3 dev), but I keep reading that I need to instal node.js to compile it? why is that?

like image 718
Phil Avatar asked May 17 '13 23:05

Phil


1 Answers

TypeScript is a language that compiles into JavaScript. The compiler that does this, appears to be written (or at least distributed) in JavaScript. And node.js is the most common way to execute JavaScript outside a browser.

The typescript compiler is simply JavaScript, which is executed by node.js to compile things.

Why is that, you ask? Well, because that's what the developers of the compile chose to write their compiler in. It could have been any language they wanted really.

My hunch though, is that the compiler is actually written in TypeScript, and they distribute the compiled version. Yeah, a compiler written in the language it's supposed to compile, weird but possible, and beyond the scope of this question.

like image 74
Alex Wayne Avatar answered Oct 11 '22 15:10

Alex Wayne