Beginner's TypeScript Tutorial (18 exercises)

Working with Object Params

Here's a different implementation of the addTwoNumbers function:

This time the function accepts a params object with first and second properties.

Similarly to last time, we're getting the "implicitly has an 'any' type" error.


Work out how to type params as an object with a key of first that is a number and a key of second that is also a number.


We've got a similar problem here to what we had last time. We have a function argument which is giving us "Parameter 'params' implicitly has an 'any' type," except it's a little bit different because we've still got our addTwoNumbers function, except that we're parsing them in as an object into our function.

We somehow need to work out how to type this params as an object type with a key of first, which is a number and a key of second, which is also a number. That's your challenge.