Last active
February 12, 2020 17:30
-
-
Save cenkce/aa4f89c17bf2fcc12cc44ebe88352000 to your computer and use it in GitHub Desktop.
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
// Extracts only non nested values | |
type ExtractValue<T extends {[key:string]: any}> = T extends {[key:string]: any} ? T[keyof T] : T; | |
// Recusively extracts values | |
type ExtractValues<T extends {[key:string]: any}> = T extends {[key:string]: any} ? ExtractValue<T[keyof T]> : never; | |
type ValuesOfComplexType = ExtractValues<ComplexType>; | |
// or | |
type ValuesOfComplexType = ExtractValues<typeof ComplexConstants>; | |
// assings the values | |
// "any value 1" | "any value 2" | "any value 3" | "any value 4" ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment