TypeScript · Conditional Types · Junior · Live Coding
infer keyword — what does it do?
Short Interview Answer
Declare a type variable to capture from extends patterns.
Detailed Explanation
Example: T extends (...args: infer P) => any ? P : never. Core of ReturnType.
Example
type Elem<T> = T extends (infer U)[] ? U : T;