TypeScript 7 Corsa Beta:tsc-go,前端工具链十年最大原生化
影响力:TypeScript 7.0 Beta(2026-04-21 发布)= 微软把 tsc 用 Go 重写,二进制名
tsgo;type-checking 等价 6.0(port,非 rewrite);VS Code 1.5M LOC 77.8s → 7.5s(10.4×)。 干活密度:🟢 干活级 预计 GA:2026 年 6 月底 / 7 月初
🔥 影响力卡片
- TypeScript 7.0 Beta = 2026-04-21;代号 Corsa,二进制名
tsgo - 性能基准(官方):
- VS Code 1.5M LOC: 77.8s → 7.5s(10.4×)
- Playwright: 11.1s → 1.1s(10.1×)
- TypeORM: 17.5s → 1.3s(13.5×)
- date-fns: 6.5s → 0.7s(9.5×)
- 已生产试用:Bloomberg / Canva / Figma / Google / Linear / Notion / Slack / Vercel / VoidZero
- 6.0 仍是 production 推荐,不要为了快直接上 7.0 beta 进生产
🎯 为什么必读
TypeScript 慢一直是大型 monorepo 的头号痛点。Rust 化的 SWC/Oxc/Rolldown 已经把”代码 transform”那段从 100s 压到 1s,但 type checking 依赖 tsc(纯 TS 实现的编译器),无法被前端工具链替代。Corsa 是这个最后瓶颈的解决方案。
不只是性能 10× —— 它意味着 LSP 响应、CI 时间、monorepo 增量编译全部重写预算。
一句话总结
微软把 tsc 用 Go 重写(port,不是 rewrite),保持 type-checking 行为等价 6.0,在大型 codebase 上提速一个数量级。
💎 金句墙
★ “This is a port, not a rewrite. We will keep the type-checking semantics identical to 6.0.” “这是一次 port,不是 rewrite。我们会保持 type-checking 语义与 6.0 完全等价。” —— 译者点评:这句承诺很重要。如果是 rewrite,你的 codebase 可能突然出现新的 type error;port 意味着 7.0 GA 后,你 6.0 通过的代码 7.0 也通过 —— 升级的心理负担降到最低
★ “VS Code: 77.8 seconds to 7.5 seconds.” “VS Code: 77.8 秒到 7.5 秒。” —— 译者点评:这是真实大型 codebase(150 万行 TS)的官方 benchmark。10× 的提速意味着以前不能跑的”每次 commit 全量 type check”现在可以跑
📋 核心精读
1. 安装并跑 tsgo
npm install -D @typescript/native-preview
# 命令行
npx tsgo --noEmit # 等价 tsc --noEmit
npx tsgo --watch # 等价 tsc --watch
🟢 译者点评:双轨并行。tsc(Node)和 tsgo(Go)可以同时跑,跑一段时间对比是否有任何 type error 差异(理论上不应该有)。
2. CI 集成示例
# .github/workflows/typecheck.yml
name: typecheck
on: pull_request
jobs:
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm ci
- run: npx tsgo --noEmit # 用 tsgo 跑 CI
🟢 译者点评:CI 是 tsgo 第一个能落地的场景。GitHub Actions runners 5min → 30s,直接省钱。
3. 配合 isolatedDeclarations(TS 5.5+ 的”前哨”)
// tsconfig.json
{
"compilerOptions": {
"moduleResolution": "bundler", // Vite/Next 13+ 标配
"isolatedDeclarations": true, // 强制所有 export 显式标注
"noCheck": true // TS 5.6+:纯语法 emit
}
}
🟢 译者点评:这些 5.5+ 就能上的优化全部延续到 7.0 时代。isolatedDeclarations 强制 export 显式标注后,外部工具(oxc / swc / esbuild / tsdown)可并行生成 .d.ts,monorepo 实测 ~3×。这是 7.0 GA 前应该先打的底。
4. 与 tsdown 的协同
// tsdown.config.ts
import { defineConfig } from 'tsdown';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm', 'cjs'],
dts: true, // 自动 .d.ts 生成
// 开 isolatedDeclarations 走 oxc-transform fast path
});
🟢 译者点评:tsdown 是 tsup 的接班人(基于 Rolldown + Oxc,3-10× 比 tsup)。配 isolatedDeclarations,库的 .d.ts 生成几乎零成本。
5. 升级路径(GA 前 / GA 后)
| 阶段 | 推荐做法 |
|---|---|
| 现在(Beta) | tsgo 仅在本地 / CI 平行跑,生产仍 6.0 |
| 6 月 GA 前 | 准备好 isolatedDeclarations 和 moduleResolution: bundler |
| GA 后 30 天 | 灰度切到 7.0,跑回归 1-2 周 |
| GA 后 90 天 | 全量切 |
🟢 译者点评:微软自己说 7.0 GA 后会和 6.0 双轨跑 N 个版本,所以没必要急。
6. 6.0 在 7.0 期间仍是稳定渡口
# 老项目可以这么"温和"
"typescript": "^6.0.0", # 主线
"@typescript/native-preview": "..." # 平行试用
🟢 译者点评:不要为了快直接上 7.0 beta 进生产。微软的 GA 节奏是稳定的,等 GA 后 minor 版本(7.1 / 7.2)再上更安全。
🟢 译者总评
- 现在就做:本地装
@typescript/native-preview,CI 平行跑tsgo对比时间 - GA 前打底:开
isolatedDeclarations+moduleResolution: bundler,这些是 5.5/5.6 就能上的”无悔投资” - 不要 rewrite 焦虑:微软承诺 port 等价语义,你的代码不需要改一行
- 预算重做:LSP 延迟、CI 时间、monorepo 增量编译这三项的 SLA 都要重新设
- 组合拳:TypeScript 7 + Vite 8 + Rolldown = 大型 monorepo 的 dev/build/check 三链路全 Rust/Go 化