What does `type StringKeys = { [K in keyof T]: K extends string ? K : never }[keyof T]` extract?

TypeScript Professional Hard

TypeScript Professional — Hard

What does `type StringKeys = { [K in keyof T]: K extends string ? K : never }[keyof T]` extract?

Key points

  • Extracts only string keys from T
  • Excludes number and symbol keys
  • Utilizes conditional types for filtering
  • Returns a new type with only string keys

Ready to go further?

Related questions