正在打开每日关注
正在打开每日关注
Next.js 通过实验性 CLI 调用支持 TypeScript 7,绕过暂缺的 JavaScript API。
TypeScript 7 Support in Next.js TLDR: You can now enable `experimental.useTypeScriptCli` to use TypeScript 7 on next@preview Details: TypeScript 7 released with ts-go, very excited about the speedup! The release is (intentionally) missing the JavaScript API which they're aiming to release in TypeScript 7.1. Unfortunately that meant that the TypeScript 7 release as-is breaks frameworks integrating TypeScript using the JS API. Next.js uses the JS API to invoke TypeScript during "next build" and adds additional formatting so that the logs are consistent with other parts of the build. In order to support TypeScript 7 without a JS API we had to change the way TypeScript is invoked to directly use the installed `tsc` command. This change is available under experimental.useTypeScriptCli It's released as part of the Next.js 16.3 Preview. You can install it using `npm install next@preview`.
是什么 这是一项 Next.js 16.3 Preview 中的兼容性更新,目标是在 TypeScript 7 已发布、但 JavaScript API 尚未提供的过渡期,让 Next.js 能继续完成构建阶段的 TypeScript 调用。原文指出,TypeScript 7 搭载 ts-go,预期带来明显速度提升,但暂时破坏了依赖 JS API 的框架集成。
核心机制 Next.js 原本通过 JavaScript API 在 next build 中调用 TypeScript,并额外统一构建日志格式。为适配 TypeScript 7,团队改为直接执行项目中安装的 tsc 命令,并将能力放在 experimental.useTypeScriptCli 开关下。图片给出了该配置的最小启用示例。
关键洞察 这不是 TypeScript 类型系统或业务代码的变化,而是构建工具边界的调整:当底层编译器暂时缺少程序化接口时,框架可以先通过 CLI 保持生态可用,同时让用户提前获得新编译器的性能收益。
边界与风险 该能力仍处于实验阶段,且依赖 next@preview;TypeScript 7.1 计划补回 JavaScript API 后,调用路径和配置价值可能继续变化。升级前应在本地与 CI 中核对类型检查、日志输出和构建稳定性。