How much Typescript is syntax wise different than es6 / es7 . We have code like this in Typescript:
class demo {
demoProp:any;
constructor () {
//...
}
}
But es6
doesn't require :any
after property to declare it?
So should I keep using Typescript or should I learn es6
directly as it is standard JavaScript
.
Note:- I am aware that TypeScript
is said to be type based and also superset of es6
. But will ecma script
likely be TypeScript
in near future or in its next version 7
or 8
In TypeScript you have types, access modifiers and properties:
class demo {
public demoProp: any;
constructor(demoProp:any) {
this.demoProp = demoProp;
}
}
You can also have generic types and interfaces:
interface Demo<T> {
demoProp: T
}
class demo<T> implements Demo<T> {
public demoProp: T;
constructor(demoProp: T) {
this.demoProp = demoProp;
}
}
Generics and interfaces are not available in ES6 because they only make sense when you have types.
In ES6 you don't have properties, types, or access modifiers:
class demo {
constructor(demoProp) {
this.demoProp = demoProp;
}
}
I would learn TypeScript because the differences are not huge and if you learn TypeScript you will also know ES6 so you will learn two languages in one shot.
About JavaScript becoming TypeScript is not likely but is not impossible.