TypeScript Code Completion Hard +35 XP
Infer in Conditional
Complete the conditional type to extract the return type.
TypeScriptFill in the blank
type ReturnType<T> = T extends (...args: any[]) => ___ R ? R : never;Type the missing code
Show answer and explanation
Answer: infer
The 'infer' keyword in conditional types captures a type variable from the matched structure, here capturing the function's return type.
Hint: Which keyword captures a type within a conditional type?
What this challenge tests
Code Completion in TypeScript: conditional-types, infer.