-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
compose: Add types to useKeyboardShortcut
#32168
Conversation
Size Change: +3 B (0%) Total Size: 1.86 MB
ℹ️ View Unchanged
|
useKeyboartShortcut
useKeyboardShortcut
094215f
to
3432cf1
Compare
packages/compose/README.md
Outdated
_Parameters_ | ||
|
||
- _shortcuts_ `string[]|string`: Keyboard Shortcuts. | ||
- _callback_ `Function`: Shortcut callback. | ||
- _callback_ `import('mousetrap').MousetrapInstance['bind']`: Shortcut callback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just a DOM event callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not quite, from the types:
bind(
keys: string | string[],
callback: (e: ExtendedKeyboardEvent, combo: string) => any,
action?: string,
): this;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the callback be of type (e: ExtendedKeyboardEvent, combo: string) => any
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh shoot you're right, the callback is passed as the second param to bind
, my bad. I'll fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me 👍
e695333
to
299cf62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
299cf62
to
0ab8ebe
Compare
Description
Adds/corrects types to
useKeyboardShortcut
. There were pre-existing types but they weren't being type-checked.Part of #18838
How has this been tested?
Type checks pass. No runtime changes that should affect anything except for an extra null check.
Types of changes
New feature.
Checklist:
*.native.js
files for terms that need renaming or removal).