TypeScript 2.0 最终版发布了。它带来了一些新的功能,提高了开发人员的生产力,先进的TypeScript 校准和ECMAScrip的发展,为JavaScript库和工具提供了广泛的支持,并增强了语言服务,提供了跨工具的一流编辑体验。
值得关注的更新内容:
控制流分析类型
function f(condition: boolean) { let result: number; if (condition) { result = computeImportantStuff(); } // Whoops! 'result' might never have been initialized! return result; }
readonly 修饰符
class Person { readonly name: string; constructor(name: string) { if (name.length < 1) { throw new Error("Empty name!"); } this.name = name; } } // Error! 'name' is read-only. new Person("Daniel").name = "Dan";
相关链接:
有关发行说明和链接到各种平台的安装,请查看发行公布
有关新特性方面的内容,请查看What's new in TypeScript 2.0
点击Breaking changes in TypeScript 2.0 查看重大更改内容
点击fixed issues query for TypeScript 2.0, TypeScript 2.0.2和TypeScript 2.0.3,查看完整的问题修改列表
下载地址:
Visual Studio 2015 plugin (requires VS 2015 Update 3 to be installed first)
安装命令
npm install -g typescript@2.0
文章转载自:开源中国社区 [http://www.oschina.net]