tsc TypeScript 编译器是如何编译的?

How is the tsc TypeScript compiler compiled?

TypeScript 的维基百科页面提到编译器本身是用 TypeScript 编写的。

这怎么可能? TypeScript 转译为 JavaScript,而 JavaScript 通常由 Web 浏览器解释。

tsc 编译器二进制文件是如何生成的?

虽然 javascript 通常与浏览器相关联,但它也可以在服务器或命令行上使用 Node.js。 Typescript的构建过程由nodejs脚本组成。

typescript 项目的脚本可以在他们的 package.json 文件 found here. The build:compiler script runs this gulpfile, and part of what the gulp file does is run this file 中找到。该文件执行 ./lib/tsc,因此 运行 在 lib 目录中找到的打字稿编译器,然后编译传入的打字稿代码。请注意,结果不是二进制文件,而是 javascript 文件;在 ./lib/tsc

找到的相同(或相似)javascript 文件

In computer science, bootstrapping is the technique for producing a self-compiling compiler — that is, compiler (or assembler) written in the source programming language that it intends to compile. An initial core version of the compiler (the bootstrap compiler) is generated in a different language (which could be assembly language); successive expanded versions of the compiler are developed using this minimal subset of the language. The problem of compiling a self-compiling compiler has been called the chicken-or-egg problem in compiler design, and bootstrapping is a solution to this problem.

发件人:https://en.wikipedia.org/wiki/Bootstrapping_(compilers)