Skip to content

Commit

Permalink
Merge pull request #35411 from kubabutkiewicz/ts-migration/react-nati…
Browse files Browse the repository at this point in the history
…ve-key-command

[No QA][TS migration] Migrate 'react-native-key-command.js' mock to TypeScript
  • Loading branch information
nkuoch authored Feb 12, 2024
2 parents ec06e3f + 0f2dec0 commit b3c664b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 0 additions & 7 deletions __mocks__/react-native-key-command.js

This file was deleted.

9 changes: 9 additions & 0 deletions __mocks__/react-native-key-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {addListener as _addListener, constants as _constants} from 'react-native-key-command';

const registerKeyCommands = () => {};
const unregisterKeyCommands = () => {};
const constants: Partial<typeof _constants> = {};
const eventEmitter = () => {};
const addListener: typeof _addListener = () => () => {};

export {addListener, constants, eventEmitter, registerKeyCommands, unregisterKeyCommands};
5 changes: 4 additions & 1 deletion src/types/modules/react-native-key-command.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ declare module 'react-native-key-command' {
type KeyCommand = {input: string; modifierFlags?: string};

declare function addListener(keyCommand: KeyCommand, callback: (keycommandEvent: KeyCommand, event: KeyboardEvent) => void): () => void;
declare function registerKeyCommands(): void;
declare function unregisterKeyCommands(): void;
declare function eventEmitter(): void;

// eslint-disable-next-line import/prefer-default-export
export {constants, addListener};
export {constants, addListener, registerKeyCommands, unregisterKeyCommands, eventEmitter};
}

0 comments on commit b3c664b

Please sign in to comment.