MarshallOfSound / MarshallOfSound/ipc

Generated internal files use value imports for type-only symbols with verbatimModuleSyntax

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
29
Forks
3
PR merge metrics
No merged PRs in 30d

Description

## Description

When generating IPC wiring in a TypeScript project with `verbatimModuleSyntax: true`, EIPC emits mixed imports from `common/.js` where interfaces/type aliases are imported as runtime values. TypeScript rejects the generated files with `TS1484` before the app can build.

This is related to #10, but it happens inside the generated `_internal/browser` and `_internal/preload` files rather than in the public barrel re-exports.

## Generated code

Example from `src/eipc/generated/_internal/browser/WagoApp.ts` and `src/eipc/generated/_internal/preload/WagoApp.ts`:

```ts
import {
NonEmptyString,
OpenDialogProperty,
MessageBoxType,
DialogFilter,
OpenDialogOptions,
OpenDialogResult,
MessageBoxOptions,
MessageBoxResult,
IAppImpl,
IAppRenderer,
IWindowControlsImpl,
IWindowControlsRenderer,
IDockImpl,
IDockRenderer,
IAdsImpl,
IAdsRenderer,
IShellImpl,
IShellRenderer,
IDialogImpl,
IDialogRenderer,
} from "../common/WagoApp.js";
```

Only `OpenDialogProperty` and `MessageBoxType` are runtime values in this example. The other names are generated as interfaces or type aliases in `common/WagoApp.ts`.

## TypeScript error

```text
src/eipc/generated/_internal/browser/WagoApp.ts(5,10): error TS1484: 'NonEmptyString' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
src/eipc/generated/_internal/browser/WagoApp.ts(5,150): error TS1484: 'IAppImpl' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
src/eipc/generated/_internal/preload/WagoApp.ts(5,76): error TS1484: 'OpenDialogOptions' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
```

There are equivalent errors for each generated interface/type alias in both internal files.

## Expected output

The generated code should split value imports from type-only imports, for example:

```ts
import { OpenDialogProperty, MessageBoxType } from "../common/WagoApp.js";
import type {
NonEmptyString,
DialogFilter,
OpenDialogOptions,
OpenDialogResult,
MessageBoxOptions,
MessageBoxResult,
IAppImpl,
IAppRenderer,
IWindowControlsImpl,
IWindowControlsRenderer,
IDockImpl,
IDockRenderer,
IAdsImpl,
IAdsRenderer,
IShellImpl,
IShellRenderer,
IDialogImpl,
IDialogRenderer,
} from "../common/WagoApp.js";
```

## Environment

- `@marshallofsound/ipc`: 2.7.0
- TypeScript: 6.0.3
- Electron: 42.2.0
- Vite: 8.0.13
- `tsconfig.json`: `module: "preserve"`, `moduleResolution: "bundler"`, `isolatedModules: true`, `verbatimModuleSyntax: true`, `strict: true`

## Current workaround

We have to run a post-generation patch script after `generate-ipc` to rewrite those imports. That works, but it is brittle and easy to lose when the generated shape changes.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the generate-ipc command that produces src/eipc/generated/_internal/browser/WagoApp.ts and src/eipc/generated/_internal/preload/WagoApp.ts. Compare the generated imports with the common/WagoApp.ts symbols, then verify generation under verbatimModuleSyntax and confirm the generated project no longer reports TS1484 errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.