Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Last active September 6, 2020 09:08
Show Gist options
  • Save roalcantara/d260b5473129c2aa3e94304b8af33468 to your computer and use it in GitHub Desktop.
Save roalcantara/d260b5473129c2aa3e94304b8af33468 to your computer and use it in GitHub Desktop.
TypeScript 3.9 | Advanced Types: Extracts inner types and return type from function
export type FunctionInfer<F> =
F extends (...args: infer A) => infer R
? [A, R]
: never
const fn01 = (arg: number, foo: any) => arg === foo
export type Type1 = FunctionInfer<typeof fn01> // [[arg: number, foo: any], boolean]
// https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab
// https://github.com/millsp/medium/blob/master/types-curry-ramda/src/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment