← All Exercises
Type Inference in Conditional Types
advancedtypescript
Background
The infer keyword enables powerful type extraction patterns, forming the basis of ReturnType and Awaited types.
Problem
Create conditional types that extract the return type of a function and the resolved type of a Promise using infer.
Input
A function or Promise type to extract from.
Output
The extracted inner type (return type or Promise resolved type).
Sample tests
Sample 1
Input: () => string
Expected: string (return type)
Your solution
Learning objective
Master the infer keyword for type extraction in conditional types.