Skip to content

Instantly share code, notes, and snippets.

@venil7
Created June 26, 2019 20:18
Show Gist options
  • Save venil7/fdda68f3486d704d6111b5b4b44229fb to your computer and use it in GitHub Desktop.
Save venil7/fdda68f3486d704d6111b5b4b44229fb to your computer and use it in GitHub Desktop.
infer type of last element in array
type LastElem<T extends number> = [
-1,0,1,2,3,4,5
][T];
type A = [number,string, boolean];
type Z = A[LastElem<A['length']>] //boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment