Keep Only an Object's String Fields

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

Export a type PickByValue<T, V> that keeps only the properties of T whose values are of type V. Then write pickStrings(obj): return a new object with only the properties of obj whose values are strings, in their original order. Type it as PickByValue of its input and string, so the result has exactly the string fields and reading any other field is a type error.

Your code must pass

  • Keeps only string values, in order
  • Returns an empty object when there are none
  • Leaves obj unchanged
  • Has no type errors
  • Result has only the string fields
  • PickByValue works for any value type