Skip to content

chore: introduce TypeScript toolchain and typed preload contract#5

Open
DoyleDev wants to merge 1 commit intomainfrom
chore/typescript-toolchain
Open

chore: introduce TypeScript toolchain and typed preload contract#5
DoyleDev wants to merge 1 commit intomainfrom
chore/typescript-toolchain

Conversation

@DoyleDev
Copy link
Copy Markdown
Collaborator

@DoyleDev DoyleDev commented May 7, 2026

Summary

PR 1 of the JS→TS migration plan in TYPESCRIPT_MIGRATION.md. Sets up the toolchain and ports the highest-ROI seam first: the IPC bridge between preload and renderer.

  • tsconfig: strict mode, ES2022, CommonJS, output to build/ts/
  • src/shared/api.ts: typed MasonApi contract — every method exposed on window.api. Several payloads stay unknown until renderer modules get ported and we know the precise shapes.
  • src/preload.ts (was preload.js): same runtime, now compiled and type-checked against MasonApi.
  • src/types/window.d.ts: ambient declaration so renderer JS will eventually see window.api as MasonApi.
  • main.js: webPreferences.preload now points at build/ts/preload.js (the compiled output).
  • electron-builder: files includes build/ts/**.
  • npm scripts: build:ts, typecheck, all build/start commands chain build:ts first.

No runtime change. No version bump (chore — release once renderer migration progresses).

Test plan

  • npm install then npm start — app boots, OAuth/models/MCP all work the same as 1.3.9.
  • npm run typecheck — passes with strict mode.
  • npm run dist produces a working bundle with build/ts/preload.js inside.
  • CI: each pr-build-* job runs npm run dist which now includes tsc — type errors fail the PR.

Follow-ups

Per TYPESCRIPT_MIGRATION.md: port renderer modules smallest-first (state.js → utils.js → markdown.js → … → chat.js), then main.js last.

This pull request and its description were written by Isaac.

PR 1 of the JS→TS migration. Sets up tsconfig + the typed MasonApi
contract in src/shared/api.ts and ports preload.js → src/preload.ts.
Renderer modules and main.js stay JS for now and get ported in
follow-on PRs.

- tsconfig: strict mode, ES2022, CommonJS output to build/ts/
- src/preload.ts compiles to build/ts/preload.js (gitignored)
- main.js webPreferences.preload now points at the compiled output
- electron-builder files array includes build/ts/**
- npm scripts: build:ts compiles, typecheck runs --noEmit, all
  build commands chain build:ts first
- typescript 5.9.3 added as devDep (already in node_modules tree)

Co-authored-by: Isaac
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.

1 participant