Skip to content
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

[No QA][TS migration] Migrate 'react-native-key-command.js' mock to TypeScript #35411

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about following this model for this PR too? A ReactNativeKeyCommandMock type, etc..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cant do that , refactoring to that make that tests are failing

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 = () => {};
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about these functions? Should we add them to react-native-key-command.d.ts and add typing in this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's add them to react-native-key-command.d.ts @kubabutkiewicz

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};
}
Loading