In TypeScript I am used to declaring variable types using a syntax such as follows
function f(input: MyClassType)
However I have not seen such a syntax in ES6 or am I missing something here. The same I would declare in ES6
function f(input)
My main point here is that the parameter type declaration is missing.
However I have not seen such a syntax in ES6 or am I missing something here.
You are not missing something.
ES6 !== TypeScript
TypeScript is not the same thing as ES6 at all. ES6 is not a typed language. You don't declare a variable or a parameter with a type in Javascript. So, if you somehow had a thought that ES6 was supposed to implement all the syntax used in TypeScript, that's incorrect.
ES6 did implement the class
syntax which is pretty similar to what TypeScript was using (but without the types). But, that's just a similarity. ES6 is not a typed language and does not have variables with type declarations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With