Created
January 7, 2020 14:56
-
-
Save beshanoe/7110c158243662dbc57254e2e5648398 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
type TypeMap = { | |
'number?'?: number; | |
number: number; | |
'string?'?: string; | |
string: string; | |
'boolean?'?: boolean; | |
boolean: boolean; | |
}; | |
type OptionsArg = { | |
[key: string]: [keyof TypeMap, string] | keyof TypeMap | OptionsArg; | |
}; | |
type Options<O extends OptionsArg> = { | |
[key in keyof O]: O[key][0] extends keyof TypeMap | |
? TypeMap[O[key][0]] | |
: O[key] extends keyof TypeMap | |
? TypeMap[O[key]] | |
: O[key] extends OptionsArg | |
? Options<O[key]> | |
: never; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment