Complete the code to create a type that picks only the 'name' property from the User type.
type User = { name: string; age: number; email: string };
type UserName = Pick<User, [1]>;The Pick type selects the specified keys from the given type. Here, we want only the 'name' property.
Complete the code to pick both 'name' and 'email' properties from the User type.
type User = { name: string; age: number; email: string };
type ContactInfo = Pick<User, [1]>;To pick multiple properties, use a union of string literals separated by |.
Fix the error in the code to correctly pick the 'age' property from the Person type.
type Person = { name: string; age: number; location: string };
type PersonAge = Pick<Person, [1]>;The keys in Pick must be string literals representing property names, so they need to be in quotes.
Fill all three blanks to create a type that picks 'title' and 'completed' from the Task type.
type Task = { id: number; title: string; completed: boolean };
type TaskSummary = Pick<Task, [1] [2] [3]>;& instead of pipe |.Use the pipe | to combine keys inside Pick to select multiple properties.
Fill all three blanks to create a type that picks 'username' and 'email' from the Account type.
type Account = { username: string; email: string; password: string; isActive: boolean };
type AccountInfo = Pick<Account, [1] [2] [3]>;To pick multiple properties, list them as string literals separated by pipes |. Here, 'username' and 'email' are picked; 'isActive' is not included because only two blanks are for keys and one for the separator.