What does the following function signature demonstrate? function pick(obj: T, keys: K[]): Pick

TypeScript Associate Hard

TypeScript Associate — Hard

What does the following function signature demonstrate? function pick(obj: T, keys: K[]): Pick

Key points

  • TypeScript's `Pick` utility type is used to select specific properties from an object.
  • The function `pick` takes an object `obj` of type T and an array of keys `K[]`.
  • By specifying the keys in the `keys` array, the function returns a new object with only those properties.
  • The return type of the function is determined based on the keys provided.

Ready to go further?

Related questions