[英]React Hotkeys keymap gives type error in typescript
I'm using the example in the docs我正在使用文档中的示例
const keyMap = {
CONTRACT: "alt+down",
COMMAND_DOWN: { sequence: "command", action: "keydown" }
};
I'm getting this error.我收到这个错误。
No overload matches this call.
Overload 1 of 2, '(props: Readonly<GlobalHotKeysProps>): GlobalHotKeys', gave the following error.
Type '{ CONTRACT: string; COMMAND_DOWN: { sequence: string; action: string; }; }' is not assignable to type 'KeyMap'.
Property 'COMMAND_DOWN' is incompatible with index signature.
Type '{ sequence: string; action: string; }' is not assignable to type 'KeySequence'.
Property 'sequences' is missing in type '{ sequence: string; action: string; }' but required in type 'ExtendedKeyMapOptions'.
Overload 2 of 2, '(props: GlobalHotKeysProps, context?: any): GlobalHotKeys', gave the following error.
Type '{ CONTRACT: string; COMMAND_DOWN: { sequence: string; action: string; }; }' is not assignable to type 'KeyMap'. TS2769
React Hotkeys: https://github.com/greena13/react-hotkeys反应热键: https://github.com/greena13/react-hotkeys
You have to specify the datatype of keyMap as KeyMap.您必须将 keyMap 的数据类型指定为 KeyMap。
import { KeyMap } from 'react-hotkeys';
const keyMap: KeyMap = {
CONTRACT: "alt+down",
COMMAND_DOWN: { sequence: "command", action: "keydown" }
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.