Typing Async Functions
Let's go deeper into function types.
Here we have a
This function takes in an asynchronous
createUser function. It returns a promise that includes a
userId string is then used in a call to
getUser which would be a database call or something similar.
getUser are currently typed as
Your challenge is to type the functions so that the errors go away.
Reference the function typing and Promise syntax that we've looked at previously for help.
Let's go deeper into function types here. We've got a function which is createThenGetUser. It takes in a createUser function which is asynchronous. It returns a promise, and it returns a promise including a string. Then, we use that string, which is the userID we've just created from createUser, to get the user. This might be a different database call or something similar.
Both of these are currently types as unknown. Your challenge is to work out how we can type these properly, so that these errors go away, using the function syntax that we've had before and maybe using some of the promise syntax that we've had before too.