Explain the 'infer' keyword in the context of conditional types.
Updated May 4, 2026
Short answer
The 'infer' keyword allows you to declare a type variable within a conditional type's 'extends' clause to extract a specific type.
Deep explanation
In advanced type manipulation, you often need to 'unwrap' a type—for example, getting the element type of an array or the return type of a function. The 'infer' keyword provides a way to ask TypeScript to guess what a type is during the evaluation of a conditional. It can only be used within the extends clause of a conditional type.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro