Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Last active September 6, 2020 09:07
Show Gist options
  • Save roalcantara/4e8ecd4fdaa176ef2517ce59d0eea40a to your computer and use it in GitHub Desktop.
Save roalcantara/4e8ecd4fdaa176ef2517ce59d0eea40a to your computer and use it in GitHub Desktop.
TypeScript 3.9 | Advanced Types: Extracts types from a tuple
type TupleInfer<T> =
T extends [infer A, ...(infer B)[]]
? [A, B]
: never
type Type1 = TupleInfer<[name: string, age: number, single: boolean]> // [string, number | 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