Created
June 26, 2019 20:18
-
-
Save venil7/fdda68f3486d704d6111b5b4b44229fb to your computer and use it in GitHub Desktop.
infer type of last element in array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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