Working with Object Params
Here's a different implementation of the addTwoNumbers
function:
export const addTwoNumbers = (params) => {
return params.first + params.second;
};
This time the function accepts a params
object with first
and second
properties.
{
first: 2,
second: 4,
}
Similarly to last time, we're getting the "implicitly has an 'any' type" error.
Challenge
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.
Transcript
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.