Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the tsc TypeScript compiler compiled?

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?

like image 727
Alex Coleman Avatar asked Mar 23 '26 12:03

Alex Coleman


1 Answers

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

like image 191
Nicholas Tower Avatar answered Mar 26 '26 08:03

Nicholas Tower



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!