Combining Types to Create New Types
Continuing with User
and Post
, we now have a getDefaultUserAndPosts
function that has an unknown
return type:
export const getDefaultUserAndPosts = (): unknown => {
return {
id: "1",
firstName: "Matt",
lastName: "Pocock",
posts: [
{
id: "1",
Transcript
0:00 In this exercise I want you to find the return type for getDefaultUserAndPosts. We're typing it as unknown here, but what we really want it to be is user and an array of posts in a posts object here.
0:17 So we could do what we did last time and do the extends clause, but I want you to find a different solution here. Your only changes should be within this little area there. You should be able to find a way to get this to work and have this non-error down here.