Skip to content

Renderer bridge type and TypeScript preload #238

Closed

Description

@jtklein-agents

Parent

Part of #236.

PR base

Open the pull request against spec/236-page-typescript (cut from master), not master. When that branch is missing, create it from origin/master and push it first.

What to build

The Renderer bridge has one declared type. A types-only module in the shared folder declares a RendererBridge interface; it is declared, not derived from the preload, because the ipc invoke call types every result as any. The preload is TypeScript and its exposed object is checked against the interface with satisfies. A global Window declaration adds rendererBridge, so a TypeScript Page file reads it with no cast. Bridge behaviour, channels and exposed methods do not change.

Acceptance criteria

  • A types-only module in the shared folder declares RendererBridge, naming every member the preload exposes, with the types that are free today; later leaves tighten the members their files call
  • The preload is TypeScript with explicit types, and its exposed object is checked with satisfies RendererBridge
  • A global Window declaration adds rendererBridge; the cast is removed from the page bootstrap and from every already-TypeScript Page file
  • Still-JavaScript Page files keep their cast until their own leaf
  • Crossing payloads are typed once, in main: main exports the types it already declares beside its handlers (additive exports only) and the bridge type module imports them type-only, so the Page loads no main-process code and no channel strings
  • The Renderer bridge cast rule in the tracker conventions is replaced by the no-cast rule, and the crossing-types exception to "inject types stay module-local" is noted under TypeScript renames in the coding standards
  • The preload launch test, its proof files and the packaging-bridge test still pass; Jest stand-ins for the bridge stay untyped JavaScript
  • Each file is whole-file renamed to .ts (.tsx when it holds JSX), keeps its shape and gains explicit types: no behaviour change, no refactor, no file split, MobX annotation maps untouched
  • These files have zero diagnostics under plain tsc and under --noImplicitAny, and hold no written any
  • yarn typecheck:baseline passes; every baseline line this leaf clears is deleted, and a still-JavaScript caller line whose fingerprint this leaf changes is rewritten in the same change
  • Every test, script and config entry that opens a renamed file by fixed path uses the new extension; import specifiers stay extensionless
  • A Renderer bridge call in these files reads window.rendererBridge with no cast, still inside each method (not once at module load), and the RendererBridge members these files call are tightened; a crossing payload type lives in main and is imported type-only
  • A bug typing exposes (a diagnostic that cannot clear without a runtime change) keeps its behaviour, gets the narrowest accommodation (a widened type, else a @ts-expect-error with a one-line reason), is filed as its own issue outside Spec: page TypeScript #236 and is linked from the pull request
  • yarn lint and yarn react-test pass, the tests changing only where a fixed path moved; yarn build still emits the main, preload and page output
  • tsconfig.json is unchanged: strict and noImplicitAny stay off, allowJs stays on

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions