[mousetrap] Fix different from the actual return types (#36543)

* Fix MousetrapStatic returned type

* Fix MousetrapInstance returned type
This commit is contained in:
Mitsuka Hanakura a.k.a. ragg
2019-07-01 11:07:13 -07:00
committed by Ryan Cavanaugh
parent 62ca99d819
commit 1d5b54b3fd
2 changed files with 13 additions and 12 deletions
+9 -9
View File
@@ -1,6 +1,6 @@
// Type definitions for Mousetrap 1.6.x
// Project: http://craig.is/killing/mice
// Definitions by: Dániel Tar <https://github.com/qcz>, Alan Choi <https://github.com/alanhchoi>, Nic Barker <https://github.com/nicbarker>
// Definitions by: Dániel Tar <https://github.com/qcz>, Alan Choi <https://github.com/alanhchoi>, Nic Barker <https://github.com/nicbarker>, Mitsuka Hanakura a.k.a ragg <https://github.com/ra-gg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -13,10 +13,10 @@ interface MousetrapStatic {
new (el?: Element): MousetrapInstance;
addKeycodes(keycodes: { [key: number]: string }): void;
stopCallback: (e: ExtendedKeyboardEvent, element: Element, combo: string) => boolean;
bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void;
unbind(keys: string|string[], action?: string): void;
trigger(keys: string, action?: string): void;
reset(): void;
bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): MousetrapInstance;
unbind(keys: string|string[], action?: string): MousetrapInstance;
trigger(keys: string, action?: string): MousetrapInstance;
reset(): MousetrapInstance;
/** https://craig.is/killing/mice#extensions.global */
bindGlobal(keyArray: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void;
@@ -24,11 +24,11 @@ interface MousetrapStatic {
interface MousetrapInstance {
stopCallback: (e: ExtendedKeyboardEvent, element: Element, combo: string) => boolean;
bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void;
unbind(keys: string|string[], action?: string): void;
trigger(keys: string, action?: string): void;
bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): this;
unbind(keys: string|string[], action?: string): this;
trigger(keys: string, action?: string): this;
handleKey(character: string, modifiers: string[], e: ExtendedKeyboardEvent): void;
reset(): void;
reset(): this;
}
declare var Mousetrap: MousetrapStatic;
+4 -3
View File
@@ -1,8 +1,9 @@
/// <reference types="jquery"/>
Mousetrap.bind('4', function() { console.log('4'); });
Mousetrap.bind("?", function() { console.log('show shortcuts!'); });
Mousetrap.bind('esc', function() { console.log('escape'); }, 'keyup');
Mousetrap
.bind('4', function() { console.log('4'); })
.bind("?", function() { console.log('show shortcuts!'); })
.bind('esc', function() { console.log('escape'); }, 'keyup');
// combinations
Mousetrap.bind('command+shift+K', function() { console.log('command shift k'); });