简体   繁体   English

Angular 2.0:Typescript是否支持ES6的所有功能?

[英]Angular 2.0 : Does Typescript support all the features of ES6?

Typescript started by claiming that it is a superset of Javascript. 打字稿开始声称它是Javascript的超集。 Now with ES6 around the corner. 现在ES6即将到来。 Does the current typescript transpiler/compiler support all the es6 features and syntax as it is or does it deviate from es6 interms of syntax for module export/import, arrow functions, etc? 当前的脚本编写器转换器/编译器是否支持所有es6功能和语法,或者它是否与模块导出/导入,箭头函数等的语法的es6间隔不同?

I am asking because I am trying to learn angular 2.0 but am not able to decide whether to follow typescript path or vanilla JS path. 我问,因为我正在尝试学习角度2.0,但我无法决定是否遵循打字稿路径或香草JS路径。

Regarding features, see What's new in TypeScript and the Roadmap . 关于功能,请参阅TypeScript路线图中 的新功能。 ( There doesn't seem to be any page that directly compares ES6/ES2015 features to TypeScript though. See @alexpod's answer.) 似乎没有任何页面直接将ES6 / ES2015功能与TypeScript进行比较。 请参阅@ alexpod的答案。)

I suggest you use TypeScript, if for nothing else, for the extra type checking. 我建议你使用TypeScript,如果没有别的话,进行额外的类型检查。 When Angular converted their code over to TypeScript, it revealed a number of bugs. 当Angular将其代码转换为TypeScript时,它会发现许多错误。

TypeScript's primary purpose is not to add features to JavaScript – as is the purpose of ES2015 – but to make it easier and safer for developers to write and maintain large JavaScript applications. TypeScript的主要目的不是为JavaScript添加功能 - 这是ES2015的目的 - 而是让开发人员更容易,更安全地编写和维护大型JavaScript应用程序。 The primary benefit of TypeScript shows up before your application runs – when you're writing or maintaining code. TypeScript的主要优点在应用程序运行之前显示 - 当您编写或维护代码时。 Intellisense, code completion, type checking, etc. 智能感知,代码完成,类型检查等

Look at this table . 看看这张桌子 It will show you what typescript and other transpilers/environments support right now. 它将显示您现在支持的打字稿和其他转发器/环境。

On top of Mark's answer , I should add that TypeScript and other transpilers allow you to use several ES6 features today. Mark的回答之上,我应该补充一点,TypeScript和其他转换器允许您今天使用几个ES6功能。 I wouldn't dream of launching a public facing website built entirely using ES6 today (early 2017), because old browsers don't die easy. 我不会梦想今天(2017年初)推出一个完全使用ES6构建的面向公众的网站,因为旧的浏览器并不容易。 TypeScript removes that inhibition altogether and also adds some innovations of its own. TypeScript完全消除了这种抑制,并且还增加了一些自己的创新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM