DEV Community

Discussion on: To Typescript Or Not To?

 
miketalbot profile image
Mike Talbot ⭐

Or use JSDoc...

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

wdy need to track those types of arguments? when you create or consume an API there's a contract (on REST APIs) or a Schema (in GraphQL APIs) so you'll know which kind of data you are retrieving at this exact point.

BTW most of time you don't need to have a specific type.

Imagine you retrieve data from whatever source and you need to print this data inside some node element, something like

/*
* Receives an object with the props
* name
* age
*/
function doStuff(data) {
  return `Hello ${data.name}, we'll send you a cake for your ${data.age} birthday!`;
}

Can you spot any issue for having dynamic typed props here?