TypeScript `infer`
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
Use the `infer` keyword within conditional types to extract specific types from complex structures, such as the return type of a function.
Back to Tips