You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The KeySequencetype is defined in such a way that it's difficult to define an object of type ExtendedKeyMapOptions without the use of the as keyword. For example:
export const globalKeyMap = {
ZOOM_IN_OUT: {
name: "Zoom video in / out",
sequences: ["shift+=", "shift+-"]
},
};
will result in the following:
No overload matches this call.
Overload 1 of 2, '(props: Readonly<GlobalHotKeysProps>): GlobalHotKeys', gave the following error.
Type '{ ZOOM_IN_OUT: { name: string; sequences: string[]; }; }' is not assignable to type 'KeyMap'.
Property 'ZOOM_IN_OUT' is incompatible with index signature.
Type '{ name: string; sequences: string[]; }' is not assignable to type 'KeySequence'.
Type '{ name: string; sequences: string[]; }' is missing the following properties from type 'ExtendedKeyMapOptions': sequence, action
Overload 2 of 2, '(props: GlobalHotKeysProps, context?: any): GlobalHotKeys', gave the following error.
Type '{ ZOOM_IN_OUT: { name: string; sequences: string[]; }; }' is not assignable to type 'KeyMap'. TS2769
I believe removing the extends from ExtendedKeyMapOptions would provide the desired type structure needed.
How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc)
Both HotKeys and GlobalHotKeys (but I believe this issue is present when defining any KeyMap).
Expected behavior
I should be able to define my KeySequence object without the need to cast or use the as keyword.
Platform (please complete the following information):
Version of react-hotkeys: ^2.0.0
Browser [e.g. chrome, safari]: N/A
OS: [e.g. iOS]: N/A
Are you willing and able to create a PR request to fix this issue?
Yes
The text was updated successfully, but these errors were encountered:
Describe the bug
The
KeySequence
type is defined in such a way that it's difficult to define an object of typeExtendedKeyMapOptions
without the use of theas
keyword. For example:will result in the following:
I believe removing the
extends
fromExtendedKeyMapOptions
would provide the desired type structure needed.How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc)
Both
HotKeys
andGlobalHotKeys
(but I believe this issue is present when defining anyKeyMap
).Expected behavior
I should be able to define my
KeySequence
object without the need to cast or use theas
keyword.Platform (please complete the following information):
^2.0.0
N/A
N/A
Are you willing and able to create a PR request to fix this issue?
Yes
The text was updated successfully, but these errors were encountered: