Open
Description
See:
- http://stackoverflow.com/a/40843364/187650
- Static types for dynamically named properties microsoft/TypeScript#11929
change the options to the new keyof.
snippet from stackoverflow post: http://stackoverflow.com/a/40843364/187650
type toolbarOptionsMap = {
'style': 'bold' | 'italic' | 'underline',
'font': 'strikethrough' | 'superscript' | 'subscript'
...
}
type toolbarOption<T extends keyof toolbarOptionsMap> = [T, toolbarOptionsMap[T][]];
// keyof toolbarOptionsMap = 'style' | 'font'
// T extends keyof toolbarOptionsMap, so is one of those strings.
// toolbarOptionsMap[T] is the type of the corresponding value for T
// Then we just make a list of these
type toolbar = toolbarOption<any>[];