What does the following ‘infer’ usage extract? type PromiseValue = T extends Promise ? PromiseValue : T;

TypeScript Professional Hard

TypeScript Professional — Hard

What does the following ‘infer’ usage extract? type PromiseValue = T extends Promise ? PromiseValue : T;

Key points

  • 'Infer' is used to conditionally extract types based on a condition
  • This process continues until a non-Promise type is found
  • It helps in working with complex nested Promise types efficiently

Ready to go further?

Related questions