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

Type safety for IPC messages #877

Merged
merged 9 commits into from
Feb 10, 2025
Merged

Conversation

fredrikekelund
Copy link
Contributor

Related issues

Proposed Changes

This PR adds type definitions for the IPC messages used in the app. useIpcListener now checks the type and automatically senses the callback argument types. I've also added sendIpcEventToRenderer and sendIpcEventToRendererWithWindow as type-safe wrappers around BrowserWindow.webContents.send.

Testing Instructions

Code review and some light smoke testing should suffice.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund requested a review from a team February 3, 2025 13:58
@fredrikekelund fredrikekelund self-assigned this Feb 3, 2025
Copy link
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

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

LGTM And smoke tested a bit - works still well 👍

src/index.ts Outdated
@@ -14,6 +14,7 @@ import { __ } from '@wordpress/i18n';
import packageJson from '../package.json';
import { PROTOCOL_PREFIX } from './constants';
import * as ipcHandlers from './ipc-handlers';
import { sendIpcEventToRenderer } from './ipc-utils';
Copy link
Contributor

Choose a reason for hiding this comment

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

unused

Suggested change
import { sendIpcEventToRenderer } from './ipc-utils';

@fredrikekelund fredrikekelund merged commit 4c3f544 into trunk Feb 10, 2025
7 checks passed
@fredrikekelund fredrikekelund deleted the f26d/ipc-events-type-safety branch February 10, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants