From 47efc87bca1e127417c7f55c5126b0345e892b65 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 30 Jan 2024 16:07:38 +0100 Subject: [PATCH 1/3] ref: move react-native-key-command mock to TS --- .../{react-native-key-command.js => react-native-key-command.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename __mocks__/{react-native-key-command.js => react-native-key-command.ts} (100%) diff --git a/__mocks__/react-native-key-command.js b/__mocks__/react-native-key-command.ts similarity index 100% rename from __mocks__/react-native-key-command.js rename to __mocks__/react-native-key-command.ts From 14351baa15c447138b3938b9a61a13eb0b92e1e5 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Wed, 31 Jan 2024 13:50:38 +0100 Subject: [PATCH 2/3] fix: changed types for mock --- __mocks__/react-native-key-command.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/__mocks__/react-native-key-command.ts b/__mocks__/react-native-key-command.ts index 5bd02dfd121d..288b7847684d 100644 --- a/__mocks__/react-native-key-command.ts +++ b/__mocks__/react-native-key-command.ts @@ -1,7 +1,9 @@ +import type {addListener as _addListener, constants as _constants} from 'react-native-key-command'; + const registerKeyCommands = () => {}; const unregisterKeyCommands = () => {}; -const constants = {}; +const constants: Partial = {}; const eventEmitter = () => {}; -const addListener = () => {}; +const addListener: typeof _addListener = () => () => {}; -export {registerKeyCommands, unregisterKeyCommands, constants, eventEmitter, addListener}; +export {addListener, constants, eventEmitter, registerKeyCommands, unregisterKeyCommands}; From 1ecde6c67d327057809212a1144f1fb3b96a8ec7 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Fri, 2 Feb 2024 17:24:45 +0100 Subject: [PATCH 3/3] fix: added missing functions declariation into module --- src/types/modules/react-native-key-command.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/types/modules/react-native-key-command.d.ts b/src/types/modules/react-native-key-command.d.ts index 4c7f07bd6d7e..d7f9641c5033 100644 --- a/src/types/modules/react-native-key-command.d.ts +++ b/src/types/modules/react-native-key-command.d.ts @@ -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}; }