@WorldHu 在 【学习笔记】TS 生命周期 中发帖
一次 tsc 检查大致经历:
读取 tsconfig.json。
根据 include、exclude、files 建立源文件列表(过程中已经生成 AST)。
Binder 建立符号表:把变量、函数、类型、模块绑定成 symbol。
Checker 做类型检查:推断、收窄、泛型实例化、兼容性判断。
Transformer / Emitter 输出 JS、.d.ts、source map。
1.1 读取 tsconfig.json 文件
ts 执行,也就是编译文件时,先去查找 tsconfig.json 入口文件
先读取配置,也就是得到要编译谁?不编译谁?要怎么编译?
tsc
│
├─ 读取 tsconfig
│
├─ 得到 CompilerOptions
│
├─ 得到 include/exclude
│
├─ 处理 extends
│
└─ 得到 ParsedCommandLi...