chore: introduce TypeScript toolchain and typed preload contract#5
Open
chore: introduce TypeScript toolchain and typed preload contract#5
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
build/ts/src/shared/api.ts: typedMasonApicontract — every method exposed onwindow.api. Several payloads stayunknownuntil renderer modules get ported and we know the precise shapes.src/preload.ts(waspreload.js): same runtime, now compiled and type-checked againstMasonApi.src/types/window.d.ts: ambient declaration so renderer JS will eventually seewindow.apiasMasonApi.webPreferences.preloadnow points atbuild/ts/preload.js(the compiled output).filesincludesbuild/ts/**.build:ts,typecheck, all build/start commands chainbuild:tsfirst.No runtime change. No version bump (chore — release once renderer migration progresses).
Test plan
npm installthennpm start— app boots, OAuth/models/MCP all work the same as 1.3.9.npm run typecheck— passes with strict mode.npm run distproduces a working bundle withbuild/ts/preload.jsinside.pr-build-*job runsnpm run distwhich now includestsc— 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.