-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript 2.1: use keyof #1
Comments
You mentioned on your SO question that you've attempted to apply this to your existing code, and it's not working. So that I can help, can you show me some code that's using |
Currently, Out of office but will try to give more details soon. type toolbarStyleGroupOptions = 'style' | 'bold' | 'italic' | 'underline' | 'clear';
type toolbarFontGroupOptions = 'strikethrough' | 'superscript' | 'subscript';
type toolbarFontsizeGroupOptions = 'fontsize';
type toolbarColorGroupOptions = 'color';
type toolbarParaGroupOptions = 'ul' | 'ol' | 'paragraph';
type toolbarHeightGroupOptions = 'height';
type toolbarTableGroupOptions = 'table';
type toolbarInsertGroupOptions = 'link' | 'picture' | 'hr';
type toolbarViewGroupOptions = 'fullscreen' | 'codeview';
type toolbarHelpGroupOptions = 'help';
//type toolbarDef = [string, string[]][];
type toolbarDef = [
['style', toolbarStyleGroupOptions[]]
| ['font', toolbarFontGroupOptions[]]
| ['fontsize', toolbarFontsizeGroupOptions[]]
| ['color', toolbarColorGroupOptions[]]
| ['para', toolbarParaGroupOptions[]]
| ['height', toolbarHeightGroupOptions[]]
| ['table', toolbarTableGroupOptions[]]
| ['insert', toolbarInsertGroupOptions[]]
| ['view', toolbarViewGroupOptions[]]
| ['help', toolbarHelpGroupOptions[]]
]; |
interface SummernoteOptions {
toolbar?: toolbar;
}
type toolbarOptionsMap = {
'style': 'style' | 'bold' | 'italic' | 'underline' | 'clear',
'font': 'strikethrough' | 'superscript' | 'subscript',
'fontsize': 'fontsize',
'color': 'color',
'para': 'ul' | 'ol' | 'paragraph',
'height': 'height',
'table': 'table',
'insert': 'link' | 'picture' | 'hr',
'view': 'fullscreen' | 'codeview',
'help': 'help'
};
type toolbarOption<T extends keyof toolbarOptionsMap> = [T, toolbarOptionsMap[T][]];
type toolbar = toolbarOption<keyof toolbarOptionsMap>[];
@pimterry this was the part. |
See:
change the options to the new keyof.
snippet from stackoverflow post: http://stackoverflow.com/a/40843364/187650
The text was updated successfully, but these errors were encountered: