5

Definitely, TypeScript is very better for JavaScript projects, it has many benefits and one of them are typed variables, also arrow functions are awesome:

const arFunc = ({ n, m }) => console.log(`${n + m + 1}`);

The above code is a JavaScript simple arrow function with destructing assignment. but I cannot understand the implementation of it on TypeScript. it is so complicated and confused me.

Assignment type of interanced variables and outputted results. this is my desire.

1 Answers1

9

You can declare the type of the parameter direclty after the parameter and the type of the return value before the arrow:

({ n, m } : { n: string, m: string } ) : void => console.log(`${n + m + 1}`)
Lux
  • 17,835
  • 5
  • 43
  • 73