4

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.

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.