Skip to content

Fixing typings to enable prefixing of ipc messages without inducing a value not used error #15

@StoneT2000

Description

@StoneT2000

Currently we do something like this

import type { MainProcessApi } from '../types';
import * as actions from './actions';

const DimensionsApi = {
  prefix: 'dim',
  actions,
} as const;

export type Dimensions = typeof DimensionsApi;

export default DimensionsApi;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
// @ts-expect-error - want to check for typing but ignore no unused locals here
const typecheck = DimensionsApi as MainProcessApi; // should error if it doesn't conform

to create the ipc channels really easily with typings so both the main and renderer process have access to proper typings for what info can go across the ipc channels. We additionally want to be able to prefix the name of the messages so we sort of scope ipc messages without cluttering. However, a consequence is that we get this unused variable error in the current implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions