北京时间7月31日,微软宣布推出 Type 3.0 正式版。
Type 3.0 是一个新的里程碑。官方表示,尽管版本号是一个大变化,但 3.0 版本几乎没有破坏性的变更(这意味着我们可以很轻松地升级到该版本),3.0 引入了一种新的灵活且可扩展的方式来构建项目、提供对参数列表进行操作新的强大支持能力、强制显式检查的新类型、更好的 JSX 支持、整体更好的错误处理,等等。
下面简单说说值得关注的更新,更详细的更新说明请移步至 发布说明。
项目引用(Project references)
这是 3.0 版本中引入的一个新概念。考虑这样一个场景 —— 对于开发者而言,为库或应用程序提供几个不同的构建步骤是相当常见的。也许你的代码库有一个 src 和一个测试目录。也许你将前端代码放在一个名为 client 的文件夹中,将 Node.js 后端代码放在名为 server 的文件夹中,每个文件夹都从共享文件夹中导入代码。也许你使用所谓的“monorepo”并且有许多项目以复杂的方式相互依赖。
官方表示,针对上述的场景,他们为 Type 3.0 开发了最重大的功能之一 ——“项目引用(project references)”。
项目引用允许 Type 项目依赖于其他 Type 项目 —— 特别是允许 tsconfig.json 文件引用其他 tsconfig.json 文件。指定这些依赖项可以更容易地将代码拆分为更小的项目,因为它为 Type (及其周围的工具)提供了一种理解构建顺序和输出结构的方法。这意味着更快的构建可以逐步工作,并支持跨项目导航、编辑和重构。由于 3.0 奠定了基础并公开了 API,因此任何构建工具都能够提供这一功能。
在JSX 中支持 defaultProps
该特性使得调用者可以通过不需要某些参数来更轻松地使用函数。
破坏性变更
API 的破坏性变更
- The deprecated internal method
LanguageService#getSourceFilehas been removed, as it has been deprecated for two years. See #24540. - The deprecated function
TypeChecker#getSymbolDisplayBuilderand associated interfaces have been removed. See #25331. The emitter and node builder should be used instead. - The deprecated functions
escapeIdentifierandunescapeIdentifierhave been removed. Due to changing how the identifier name API worked in general, they have been identity functions for a few releases, so if you need your code to behave the same way, simply removing the calls should be sufficient. Alternatively, the typesafeescapeLeadingUnderscoresandunescapeLeadingUnderscoresshould be used if the types indicate they are required (as they are used to convert to or from branded__Stringandstringtypes). - The
TypeChecker#getSuggestionForNonexistentProperty,TypeChecker#getSuggestionForNonexistentSymbol, andTypeChecker#getSuggestionForNonexistentModulemethods have been made internal, and are no longer part of our public API. See #25520.
相关链接
发布说明 https://blogs.msdn.microsoft.com/type /2018/07/30/announcing-type -3-0/ Type 3.0 新特性 https://github.com/Microsoft/Type /wiki/What's-new-in-Type #type -30 Type 3.0 文档 https://www.type lang.org/docs/handbook/release-notes/type -3-0.html 破坏性变化 https://github.com/Microsoft/Type /wiki/Breaking-Changes#type -30
下载地址
npm Visual Studio 2015 plugin Visual Studio 2017 (Select new version in project options) NuGet package
继续阅读与本文标签相同的文章
-
2019「边缘计算」大看点,点击解锁详细版云栖大会参会指南
2026-05-18栏目: 教程
-
生存还是毁灭?一文读懂挖矿木马的战略战术
2026-05-18栏目: 教程
-
数据库基础技术实践#网络安全基础技术实践课程
2026-05-18栏目: 教程
-
MySQL每组求最值的记录与每组前N条记录
2026-05-18栏目: 教程
-
OCP-052考试题库汇总(55)-CUUG内部解答版
2026-05-18栏目: 教程
