Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Last active September 6, 2020 09:07
Show Gist options
  • Save roalcantara/98226125e4c99dc8eeece72242d6c261 to your computer and use it in GitHub Desktop.
Save roalcantara/98226125e4c99dc8eeece72242d6c261 to your computer and use it in GitHub Desktop.
TypeScript 3.9 | Advanced Types: Returns an array's length
type Length<T extends any[]> = T['length']
type Length01 = Length<[]> // 0
type Length02 = Length<[any, any]> // 2
type Length03 = Length<[any, any, any]> // 3
type Length04 = Length<['a', 1, null, string]> // 4
// 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