If you have really used typescript you will find that he is actually a superset of JavaScript, a very concise description, the reason that is called typescript, is the expression of the word type (strong type), can not only have a class even strong type. Testing you may still be very difficult to understand, depending on your math and statistics courses, perhaps you do not know what is called "superset", then I will show a "doll circle."
Below, it is described that we have a set of data A, and a data b,b is a superset of a, B contains all the data of a (you can not say that A is b,b is a).
Then the situation of typescript and ECMASCRIPT6 is the same, if you can understand the case of the above reason:
In fact, the difference between the two is not very large, there are many similarities, if you are familiar with typescript, you can easily write ECMAScript6, and vice versa, but if you are a beginner does not understand the difference between their two, Suggest that you should learn typescript and ECMASCRIPT6 from the details.
What are the specific differences in our development? Let's take the IONIC2 project as an example,
If you use JS development, you need to build this project:
Ionic start MyApp Blank--v2
Then your file extension should be *.js, if you use webstrom development, do not forget to change the JavaScript compilation configuration, otherwise in development will display an error
Then the code should be:
If you are using typescript, then you should use the following command to build the project, make sure that the files you generated are *.ts, by the way webstrom for TS support is very good, that is, smart reminders a bit slow.
Ionic start MyApp blank--v2--ts
where Rootpage:any = homepage; and the Dependency injection constructor (Platform:platform) during construction is typescript proprietary.
The specifics of the difference, we show in detail below:
//EM6声明局部变量let myThing = "hello";//Typescript声明局部变量let myThing: any = "hello";
So for the dependency injection is more different, I have been high mixed, in fact, xiaoming is very stupid!
//EM6static get parameters() { return [[Platform], [Http]];} constructor(platform, http){ }
//Typescriptconstructor(platform: Platform)
In fact, the IONIC2 team uses typescript development by default, and the reason for this may be that only you are involved in development to understand, so if you do not really understand them, please do not comment.
In addition, the typescript decorator (decorator) is based on the ES7 decorator proposal, so you'll find that the difference between the two is not small.
ECMASCRIPT6 VS TypeScript