The wikipedia page for TypeScript mentions that the compiler itself is written in TypeScript.
How is this possible? TypeScript transcompiles to JavaScript, and JavaScript is typically interpreted by a web browser.
How is the tsc
compiler binary generated?
While javascript is typically associated with browsers, it can also work on servers or the command line with Node.js. Typescript's build process is composed of nodejs scripts.
The scripts for the typescript project can be found in their package.json file, found here. The build:compiler
script runs this gulpfile, and part of what the gulp file does is run this file. That file executes ./lib/tsc
, thus running the typescript compiler that's found in the lib directory, which then compiles the typescript code it was passed in. Note that the result is not a binary, it's a javascript file; the same (or similar) javascript file found at ./lib/tsc