3 Minutes With Kent

TypeScript: Don't type array method callbacks

Informações:

Sinopse

Hello friends, this is a little bit later than usual but I just wanted to get this in because I want to do this every weekday. So today I want to talk about TypeScript and in particular map. So I wrote a blog post recently that talked about converting typescript or fetch a fetch implemented or calling fetch in a function over to TypeScript because when you call fetch the return value from the dot JSON on that response is going to be any and so you have to explicitly. Give that a type annotation. And anyway, one of the as I was migrating this code one of the things that I pointed out was that like we were iterating over some of the values that came back from that response.json call. And in the process of migrating the code if you just go about it in a certain way before you add the type annotation, you'll find that iterating over it requires that you type that map. Callback function. And so in our example, we had an array of errors that could come back from this API call and we're going to iterate over those a