Set Properties as Optional
Consider this getName
function:
export const getName = (params: { first: string; last: string }) => { if (params.last) { return `${params.first} ${params.last}`; } return params.first;};
Reading the code, we can see that we don't need to pass in a last
name in orde
Transcript
0:00 Your next challenge is a function called getName here, where you parse in a params object with the first name and the last name here, except you don't need to parse in the last name.
0:14 TypeScript doesn't seem to know this yet. It's moaning at me here by saying, "Property 'last' is missing in type blah blah blah but required in this one."
0:24 It's telling me I do need to parse the last name here. I don't want to. Figure out a way that you can type this object where last is optional.