I have defined a data type called User:
type User = {
id: string;
name?: string;
email?: string;
}
Now, I want to create a new type named UserWithName that is similar to User but with the name
property being non-optional:
type UserWithName = {
id: string;
name: string;
email?: string;
}
Instead of duplicating the type definition like I did above, I am looking for a way to generate UserWithName from User using generic utility types.
Required almost solves this issue, but it makes all properties mandatory whereas I only need to make one property mandatory.