Use `infer` inside a conditional type.
Section: Mapped and Conditional Types
Infer a return type
typescript
typescript
type GetReturn<T> = T extends (...args: never[]) => infer R ? R : never;Explanation
`infer` captures a type from a matched pattern in a conditional type.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Mapped and Conditional Types
Discriminated union pattern
Model variant objects with a shared discriminant field.
Generic identity function
Use a type parameter for reusable function typing.