Announcing TypeScript 7.0
Announcing TypeScript 7.0
TypeScript 7.0 发布公告
Today we are proud to announce the availability of TypeScript 7, a 10x faster native port of TypeScript! Since its early days, TypeScript has promised to deliver on JavaScript that scales. By bringing strong type-checking and rich tooling to the world of JavaScript, TypeScript made it possible to build non-trivial high-quality apps across platforms. 今天,我们非常自豪地宣布 TypeScript 7 正式发布,这是一个速度提升 10 倍的 TypeScript 原生移植版本!自诞生之初,TypeScript 就承诺为 JavaScript 提供可扩展的解决方案。通过将强大的类型检查和丰富的工具链引入 JavaScript 世界,TypeScript 使跨平台构建高质量、复杂的应用程序成为可能。
Last year, our team unveiled TypeScript’s next step in scaling: making every part of the toolset an order of magnitude faster. The mission was a native port of TypeScript built in Go that could make the most of modern hardware. This port was done as faithfully as possible, writing new code while maintaining the structure and logic of the original codebase to keep results consistent and compatible between the two compilers. 去年,我们的团队揭示了 TypeScript 扩展的下一步计划:将工具集的每个部分速度提升一个数量级。我们的使命是使用 Go 语言构建一个能够充分利用现代硬件性能的 TypeScript 原生移植版本。该移植过程尽可能保持忠实,在编写新代码的同时保留了原始代码库的结构和逻辑,以确保两个编译器之间的结果一致且兼容。
The key difference is that with this new codebase, TypeScript 7 brings native code speed, shared memory multithreading, and a number of new optimizations that typically yield speedups between 8x and 12x on full builds. Just as with any other release, TypeScript 7 is available via npm: npm install -D typescript. That will get you the new tsc executable in your workspace (which you can run via npx tsc).
关键的区别在于,凭借这一全新的代码库,TypeScript 7 带来了原生代码的运行速度、共享内存多线程处理,以及一系列新的优化措施,通常能使完整构建速度提升 8 到 12 倍。与以往的版本一样,TypeScript 7 可通过 npm 获取:npm install -D typescript。这将为你的工作区安装新的 tsc 可执行文件(你可以通过 npx tsc 运行它)。
Of course, a big part of the TypeScript experience is also about editor support. Your favorite code editor should easily support TypeScript 7 with its new support for the language server protocol (LSP), and its new speed and multithreading improvements. Whether you’re using something like VS Code, Visual Studio, WebStorm, or any other modern editor, TypeScript 7 should work great. Just check your editor’s documentation – for example, VS Code has a dedicated extension for TypeScript 7 that you can use today, and Visual Studio will automatically enable TypeScript 7 based on your workspace. 当然,TypeScript 体验的重要组成部分还包括编辑器支持。你最喜欢的代码编辑器应该能通过其对语言服务器协议 (LSP) 的新支持,以及新的速度和多线程改进,轻松支持 TypeScript 7。无论你使用的是 VS Code、Visual Studio、WebStorm 还是其他任何现代编辑器,TypeScript 7 都应能完美运行。只需查看编辑器的文档即可——例如,VS Code 现已提供专用的 TypeScript 7 扩展,你可以立即使用;而 Visual Studio 将根据你的工作区自动启用 TypeScript 7。
What Does A Faster TypeScript Mean?
更快的 TypeScript 意味着什么?
A faster TypeScript sounds great on paper, but what does it mean in practice? Maybe it helps to think about where TypeScript comes up at every stage of development. A typical day of development might involve opening your editor, opening a TypeScript file, and running an operation like find-all-references across your projects. Then as you’d start to make edits, maybe you’d expect auto-completions to pop up, and get red squiggles on the fly as you’d make edits. When you (and more recently, perhaps an AI agent) were ready to build your project, you’d run tsc, check the output for errors, and then run your generated code somehow. 更快的 TypeScript 在理论上听起来很棒,但在实践中意味着什么呢?思考一下 TypeScript 在开发过程的每个阶段是如何出现的或许会有所帮助。典型的开发日常可能包括:打开编辑器,打开一个 TypeScript 文件,并在整个项目中运行诸如“查找所有引用”之类的操作。当你开始编辑时,你可能期望自动补全功能弹出,并在编辑时实时看到红色波浪线提示。当你(或者最近,可能是 AI 代理)准备构建项目时,你会运行 tsc,检查输出的错误,然后以某种方式运行生成的代码。
A faster TypeScript means every part above is streamlined. Waiting for your editor to fully load your project will feel instantaneous. Delays on find-all-references, auto-completion, and diagnostics should take a fraction of the time they used to. And when you run tsc, maybe in --watch mode, you’ll be able to tighten your feedback loop and iterate faster than ever before.
更快的 TypeScript 意味着上述每个环节都得到了精简。等待编辑器完全加载项目的感觉将变得瞬时完成。在“查找所有引用”、自动补全和诊断方面的延迟将缩短至原来的几分之一。当你运行 tsc(或许是在 --watch 模式下)时,你将能够缩短反馈循环,实现比以往更快的迭代。
Performance Benchmarks
性能基准测试
You can see this on real-world projects. In fact, you can try comparing on a few open-source projects yourself. Here are the build times of running TypeScript 6 and 7 on some fairly large open source codebases. 你可以在实际项目中看到这一点。事实上,你可以亲自尝试在一些开源项目上进行对比。以下是在一些相当大的开源代码库上运行 TypeScript 6 和 7 的构建时间对比:
| Codebase | TypeScript 6 | TypeScript 7 | Speedup |
|---|---|---|---|
| vscode | 125.7s | 10.6s | 11.9x |
| sentry | 139.8s | 15.7s | 8.9x |
| bluesky | 24.3s | 2.8s | 8.7x |
| playwright | 12.8s | 1.47s | 8.7x |
| tldraw | 11.2s | 1.46s | 7.7x |
TypeScript 7 also typically does better while asking for less aggregate memory over the span of a build. TypeScript 7 在构建过程中通常表现更好,且所需的总内存更少。
| Codebase | TypeScript 6 | TypeScript 7 | Memory Delta |
|---|---|---|---|
| vscode | 5.2GB | 4.2GB | -18% |
| sentry | 4.9GB | 4.6GB | -6% |
| bluesky | 1.8GB | 1.3GB | -26% |
| playwright | 1.0GB | 0.9GB | -11% |
| tldraw | 0.6GB | 0.5GB | -15% |
Of course, there’s more to the experience than the full build. On the same computer, opening a file with an error in the VS Code codebase would previously take about 17.5 seconds from the time you opened the editor to the time you saw the first error. With TypeScript 7, it’s under 1.3 seconds – over 13x faster. 当然,体验不仅仅在于完整构建。在同一台计算机上,在 VS Code 代码库中打开一个包含错误的文件,以前从打开编辑器到看到第一个错误大约需要 17.5 秒。而使用 TypeScript 7,这一时间缩短至 1.3 秒以内——速度提升超过 13 倍。
Battle-Tested and Ready for Production
经过实战检验,已做好生产准备
The TypeScript project contains tens of thousands of tests built over more than a decade that run on every commit on our main branch. They’ve ensured every one of our releases is stable and reliable. But TypeScript 7 is no ordinary release. Beyond our test suite, we’ve leveraged a number of different resources to make sure TypeScript 7 is solid for production use. TypeScript 项目包含十多年来构建的数万个测试用例,这些测试在主分支的每次提交时都会运行。它们确保了我们每一次发布的稳定性和可靠性。但 TypeScript 7 不是一个普通的版本。除了我们的测试套件外,我们还利用了多种不同的资源来确保 TypeScript 7 在生产环境中使用时足够稳健。
Over the last year we’ve worked with many large teams internally and externally to test TypeScript 7 on real-world codebases. The results have been overwhelmingly positive, with entire companies reporting that TypeScript 7 has been stable, fast, and easy to adopt. For example, the VS Code team recently highlighted their experience with TypeScript 7’s preview releases to move faster in their development cycle. We’ve also worked with Microsoft teams like Loop, Office, PowerBI, Teams, and Xbox to ensure that TypeScript is ready for the largest of codebases. 在过去的一年中,我们与许多内部和外部的大型团队合作,在实际代码库中测试了 TypeScript 7。结果非常积极,整个公司都反馈称 TypeScript 7 稳定、快速且易于采用。例如,VS Code 团队最近强调了他们使用 TypeScript 7 预览版的体验,这使他们的开发周期得以加快。我们还与微软内部的 Loop、Office、PowerBI、Teams 和 Xbox 等团队合作,确保 TypeScript 能够胜任最大规模的代码库。
Likewise, companies like Bloomberg, Canva, Figma, Google, Lattice, Linear, Miro, Notion, Sentry, Slack, Vanta, Vercel, VoidZero, and more have worked with us to test TypeScript 7 on their codebases and given us feedback to make it better. Additionally, we’ve rebuilt much of our broader test infrastructure to run on TypeScript 7. 同样,Bloomberg、Canva、Figma、Google、Lattice、Linear、Miro、Notion、Sentry、Slack、Vanta、Vercel、VoidZero 等公司也与我们合作,在他们的代码库上测试了 TypeScript 7,并提供了反馈以帮助我们改进。此外,我们还重建了大部分更广泛的测试基础设施,使其运行在 TypeScript 7 之上。
The combination of explicit feedback, automated crash reports, and aggressive testing has made a measurable difference in quality. In fact, our data insights have shown us that TypeScript 7.0’s new language server has actually reduced failing language server commands by over 80%, and reduced server crashes by over 60% compared to that of TypeScript 6.0. We’ve also heard some incredible feedback from teams at scale: Slack engineers have told us that TypeScript 7 eliminated 40% of their merge queue time and brought type-checking time in CI from about 7.5 minutes to 1. 明确的反馈、自动化的崩溃报告以及积极的测试相结合,在质量上产生了显著的差异。事实上,我们的数据洞察显示,与 TypeScript 6.0 相比,TypeScript 7.0 的新语言服务器将失败的语言服务器命令减少了 80% 以上,并将服务器崩溃次数减少了 60% 以上。我们还收到了一些来自大规模团队的惊人反馈:Slack 的工程师告诉我们,TypeScript 7 消除了他们 40% 的合并队列时间,并将 CI 中的类型检查时间从约 7.5 分钟缩短到了 1 分钟。