Last active
August 14, 2019 19:32
-
-
Save btoo/ee68f1326cadfc715739f80863595d56 to your computer and use it in GitHub Desktop.
infer the type of an element in an array from the array's type
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 ArrayElement<ArrayType> = | |
| ArrayType extends (infer ElementType)[] ? ElementType : | |
| ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : | |
| never; | |
| type Flatten<T> = T extends Array<infer U> ? U : T; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment