What does the following mapped type with key filtering produce? type FunctionProperties = { [K in keyof T as T[K] extends Function ? K : never]: T[K] };

TypeScript Professional Hard

TypeScript Professional — Hard

What does the following mapped type with key filtering produce? type FunctionProperties = { [K in keyof T as T[K] extends Function ? K : never]: T[K] };

Key points

  • Key filtering in mapped types selects properties based on a condition
  • The 'as' keyword is used to remap non-matching properties to 'never'
  • This technique is useful for creating specialized types based on existing types

Ready to go further?

Related questions