Repository navigation
Description
Decisions come from the wayfinder map "Map: page to TypeScript" (#225). Its child tickets #226 to #233 hold the detail; research notes sit on the research/page-ts-inventory and research/mobx7-typescript branches and the prototype on prototype/option-typing, none of them merged.
Feature branch
Child tickets open pull requests against spec/236-page-typescript (cut from master). Do not target master for these children.
Problem Statement
The main process is TypeScript, but the Page is not. The panels, the Page store, the page helpers, the preload and the three alignment parsers are still JavaScript: about 8,000 lines in 40 files. A maintainer changing the Page store or a panel gets no help from the typechecker. All 26 diagnostics left in the typecheck baseline sit in those files, so the baseline shelters old errors instead of being empty. The Page reaches the Renderer bridge through an untyped cast, so a mismatch between what the Page sends and what main expects is found only at runtime. And "no implicit any" on the TypeScript that already exists is held by review alone.
Solution
Convert every production file of the Page, the preload and the three alignment parsers to TypeScript, leaf by leaf, on one feature branch. Each file keeps its shape and gains explicit types. A CI check requires zero implicit any in every TypeScript file, and lint bans a written any. The Renderer bridge gets one declared type that the preload is checked against and the Page reads from window with no cast. The typecheck baseline ends empty. The app behaves exactly as before: a bug that typing exposes becomes its own issue, not a fix inside a leaf.
User Stories
- As a maintainer, I want every production file of the Page in TypeScript, so that the typechecker covers the whole Shell.
- As a maintainer, I want the Page store typed, so that a wrong member name or argument is caught before the app runs.
- As a maintainer, I want every panel to have a typed props interface, so that a call site that omits or misnames a prop fails the typecheck.
- As a maintainer, I want the preload in TypeScript and checked against the Renderer bridge type, so that the preload cannot drift from what the Page expects.
- As a page developer, I want to read
window.rendererBridgewith no cast, so that every bridge call is checked. - As a page developer, I want the payloads that cross the Renderer bridge typed once, in main, so that the Page and main cannot disagree about a payload's shape.
- As a page developer, I want the Page to import those crossing types as types only, so that the Page still loads no main-process code and no channel strings.
- As a maintainer, I want the three alignment parsers in TypeScript, so that the Page and main share typed parse results.
- As a maintainer, I want CI to fail on any implicit
anyin a TypeScript file, so that "full typing" is checked by a machine and not by review. - As a maintainer, I want that check to need no hand-kept list of files, so that a renamed file is covered the moment it is renamed.
- As a maintainer, I want no allowlist in that check, so that it cannot shelter a slip.
- As a maintainer, I want lint to reject a written
anyin TypeScript, so that the implicit-any check is not bypassed by typing the word. - As a maintainer, I want one lint rule set for all TypeScript under the source tree, so that Page files meet the same bar as main-process files.
- As a maintainer, I want the compiler's
strictandnoImplicitAnysettings left off, so that the remaining JavaScript (tests, settings) still typechecks as it does today. - As a maintainer, I want the typecheck baseline to end empty, so that every remaining diagnostic is a new one.
- As a maintainer, I want the baseline check to pass on an empty baseline, so that the mechanism stays for future use without a placeholder line.
- As an agent implementer, I want each leaf to delete the baseline lines it clears, so that progress shows in CI.
- As an agent implementer, I want each leaf to be whole files grouped by family, so that no file is ever half converted.
- As an agent implementer, I want only a few fixed ordering edges between leaves, so that most leaves can land in parallel.
- As an agent implementer, I want the option base converted before its subclasses, so that the subclasses inherit a typed constructor and value.
- As an agent implementer, I want one generic option base over its value and its owner, so that each option subclass states its value type once.
- As an agent implementer, I want a rule that a subclass never redeclares a base field, so that no option value is reset to
undefinedafter construction. - As an agent implementer, I want an option's owner and a panel's store-object props typed by a small module-local interface, so that a leaf does not have to wait for the store class it reads from.
- As an agent implementer, I want the MobX annotation maps left as they are, so that typing changes no observable behaviour.
- As a maintainer, I want
propTypesblocks removed when a panel gets typed props, so that there is one description of a panel's props and no dead code. - As a page developer, I want each prop's required or optional status carried over exactly, so that no panel's contract loosens or tightens.
- As a maintainer, I want the direct
prop-typesdependency removed once nothing imports it, so that the manifest lists only what the Page uses. - As a maintainer, I want types for
lodashandd3-arrayinstalled as dev dependencies, so that their callers are checked without hand-written declarations. - As a user of the app, I want it to behave exactly as before the conversion, so that a typing effort changes nothing I can see.
- As a maintainer, I want a bug that typing exposes filed as its own issue, so that a behaviour change is reviewed by itself.
- As an agent implementer, I want a fixed rule for meeting such a bug (keep the behaviour, widen the type or add a reasoned
@ts-expect-error, file an issue, carry on), so that a leaf never stalls on it. - As a maintainer, I want each
@ts-expect-errorto carry its reason, so that it fails by itself, with context, once the bug is fixed. - As a reviewer, I want each bug issue linked from the pull request of the leaf that met it, so that I can tell an accommodation from a shortcut.
- As a maintainer, I want the tests and the Jest setup files to stay JavaScript, so that the conversion does not rewrite the test tree.
- As a maintainer, I want the existing Jest suites to keep passing unchanged in behaviour, so that they prove the conversion kept runtime behaviour.
- As a maintainer, I want every test, script and config entry that opens a converted file by fixed path updated in the leaf that renames it, so that no check silently stops reading its file.
- As a developer, I want
yarn buildandyarn startto keep working after each leaf, so that the feature branch always launches. - As a maintainer, I want the build config's JSX-in-
.jshandling removed once no production.jsfile holds JSX, so that the config says what the code is. - As a maintainer, I want the unused decorator-based store coverage script deleted, so that no dead tooling is left pointing at files that moved.
- As a reviewer, I want the tracker conventions and coding standards updated where a leaf changes a rule (the bridge cast rule, the Checks section, the crossing-types exception), so that later tickets inherit the new rules.
- As an upstream maintainer, I want the whole effort to arrive as one pull request from the feature branch, so that the Page is never upstream in a half-converted state.
Implementation Decisions
Scope and bar
- In scope: the production files of the Page (panels, Page store, page helpers, page entry), the preload, and the three alignment parsers in the shared folder (FASTA, PHYLIP, alignment typecheck). 40 files, 14 of them holding JSX.
- Done bar per file: renamed to
.tsor.tsx, shape kept, explicit types added, zero diagnostics with or without--noImplicitAny, its baseline lines gone. - Types only. No behaviour change, no refactor, no file split or partial conversion.
tsconfig.jsonis unchanged:strictandnoImplicitAnystay off,allowJsstays on.- Import specifiers stay extensionless.
The no-implicit-any check
- Rule: every
.tsand.tsxfile under the source tree has zero diagnostics under--noImplicitAny. The extension is the ratchet; a JavaScript file is exempt until its leaf renames it. - It is a second
tscpass inside the existingyarn typecheck:baselinecommand. One command, one CI step, no allowlist. - The two existing slips, both in the main-process model-selection module and both caused by
parse-filepathshipping no types, are fixed by a types-only module declaration in the leaf that adds the check. - Lint:
@typescript-eslint/no-explicit-anyapplies to all TypeScript. The "full typing" rule block (explicit module boundary types, annotatedcatch) widens from the main process and shared folder to all TypeScript under the source tree. The four existing violations in the already-TypeScript page components are fixed in the same leaf. - The baseline script learns to pass when the baseline file is empty. The mechanism stays.
Renderer bridge
- One declared
RendererBridgeinterface in a types-only module in the shared folder. It is declared, not derived from the preload, because the ipc invoke call types every result asany. - The preload's object is checked against it with
satisfies. - A global
Windowdeclaration addsrendererBridge, so a Page file reads it with no cast. This replaces the rule that a TypeScript Page file castswindowthroughunknown. The store-entry leaf adds the deliberatestoreglobal to the same declaration. - Call sites keep their shape: the bridge is still read from
windowinside each method, not once at module load, because tests replace it between cases. - Crossing payloads are typed once, in main. Main exports the types it already declares beside its handlers, and the bridge type module imports them type-only. This is additive exports only and an exception to "inject types stay module-local". Event payloads have no named type in main today; the leaf that first needs one adds it in main.
- The interface grows leaf by leaf. The bridge leaf names every member with the types that are free; each later leaf tightens the members its files call.
- Still-JavaScript Page files keep their
anycast until their own leaf.
Page store
-
Option base, from the prototype:
class Option<Value = unknown, Owner = unknown> { run: Owner; value: Value; // bare field, annotation map unchanged // error: ValidationError | boolean | null } // a subclass: extends Option<string[], OptionRun>
descriptionandhoverInfobecome optional constructor parameters; the options argument gets anOptionSettingsinterface. No caller changes. -
The owner is a small module-local interface holding only what that leaf reads from its owner: one per leaf file, not per class. The option base imports no store type. These interfaces stay after
Runconverts; there is no later sweep. -
A subclass never redeclares a base field to narrow its type. Class fields are defined, so a redeclaration would reset the field after
super(). The type parameter does the narrowing. -
MobX annotation maps are unchanged and need nothing extra from TypeScript: the store has no
flow, no non-public members and no options argument.
Panels
- A panel that becomes
.tsxgets an exported<Name>Propsinterface; itspropTypesblock andprop-typesimport are deleted in the same leaf (React 19 ignores them). isRequiredbecomes a required member; every other prop is optional.- Store-object props (
run,alignment,tree,citation,store) are typed by a small module-local interface, as the existing option components do. No type import of the store class. - The direct
prop-typesdependency line leaves the manifest in whichever leaf deletes the last import. The lock stanza stays; other packages still depend on it.
Untyped packages
@types/lodashand@types/d3-arrayas dev dependencies, each added by the first leaf that converts an importer (lodash: final alignment or Run;d3-array: run options).
Bugs typing exposes
- Definition: a diagnostic that cannot be cleared without changing what the code does at runtime.
- A leaf keeps the behaviour, makes the file compile with the narrowest accommodation (a widened type, else a
@ts-expect-errorwith a one-line reason), files one issue per bug outside this spec, links it from its pull request, and carries on. - Two are known and already filed: Clear console icon passes
title, which the MUI icon does not accept #234 (the clear-console icon'stitleprop, met by the app shell leaf with@ts-expect-error) and MultistateNumber.error returns a boolean, so the option always reports an error #235 (MultistateNumber.errorreturns a boolean, met by the alignment-options leaf; the option base's widenederrorcovers it). - Not bugs, cleared by types alone: the
storeglobal onwindow, the two error-dialog call sites that omit optional props, and the JSDocyupname in the option base.
Leaves
Seventeen leaves. A leaf is one pull request of whole files.
| # | Leaf | Holds |
|---|---|---|
| 1 | No-implicit-any check and lint rules | the baseline script (second pass, empty baseline passes), the lint config, the parse-filepath declaration, four lint fixes |
| 2 | Renderer bridge type and preload | the new bridge type module, the preload, the Window declaration, the cast removed from the page bootstrap, type exports in main |
| 3 | Option base | the option base class |
| 4 | Alignment parsers | FASTA parser, PHYLIP parser, alignment typecheck |
| 5 | Page helpers | paths, report, GitHub issue, promised computed, host |
| 6 | Store bases | store base, input file, ASTRAL tree, config, app store, citation |
| 7 | Alignment and part options | alignment options, part options |
| 8 | Run options | run options |
| 9 | Partition family | final partition, partition |
| 10 | Final alignment | final alignment |
| 11 | Alignment | alignment |
| 12 | Run | run (one leaf on its own) |
| 13 | Run list and store entry | run list, store entry |
| 14 | Input-file cards | alignment card, ASTRAL tree card, tree card, partition file card, partition editor |
| 15 | Run panels | input, model, output, RAxML, console, citation modal |
| 16 | App shell | error dialog, app, page entry |
| 17 | Close-out | build config leftovers, docs, the store coverage script |
Fixed order: leaf 1 first, leaf 2 second; leaf 3 before leaves 7 and 8; leaf 16 after every other conversion leaf; leaf 17 last. Everything else may land in any order or in parallel. Parallel leaves collide in the baseline file and the bridge type module; small merge conflicts there are accepted.
Per-leaf consequences:
- The page-Node-imports test reads the alignment store, the run store and the page entry by fixed path; leaves 11, 12 and 16 each update their line.
- The last four baseline lines go with leaf 13 (store entry) and leaf 16 (app).
- Leaf 1 amends the Checks section of the tracker conventions and the lint comment that names the main-process spec.
- Leaf 2 updates the Renderer bridge cast rule in the tracker conventions and notes the crossing-types exception under TypeScript renames in the coding standards.
- Leaf 17 removes the build config's JSX-in-
.jshandling, deletes the decorator-based store coverage script (the store has no decorators and nothing runs it), makes any doc edits leaves 1 and 2 did not, and updates anyTODO.mdnote.
Testing Decisions
- A good test here checks external behaviour: the existing Jest suites exercise the Page store, the panels' render and the bridge through their public surface. They stay JavaScript and must keep passing with no change other than a fixed path that moved. A leaf adds no test whose only purpose is to prove a file extension.
- Seam 1, typing:
yarn typecheck:baseline. Both passes: known diagnostics match the baseline, and no TypeScript file has an implicitany. Done for a leaf means its files' baseline lines are gone; done for the spec means the baseline is empty. - Seam 2, behaviour: the existing Jest suites (
yarn react-test): the store tests, the page render test, the preload launch test and its proof files, the page-Node-imports test. - Seam 3, lint:
yarn lintwith the widened rule set. - Seam 4, build:
yarn buildstill emits the main, preload and page output; the e2e suite runs on the built Shell as it does today. - New test code only in leaf 1: the baseline script's second pass and its empty-baseline case, beside the existing baseline helper test. That is the only new logic in the spec.
- Jest stand-ins for the bridge stay untyped JavaScript.
- Prior art: the main-process TypeScript spec (Spec: main-process TypeScript #67) and its landed leaves; the baseline helper test; the already-TypeScript option components for module-local prop interfaces.
Out of Scope
- Turning on
strictornoImplicitAnyintsconfig.json, and removingallowJs. - Converting test files and the Jest setup files.
- The settings modules and any other JavaScript outside the listed set.
- Fixing the bugs typing exposes (Clear console icon passes
title, which the MUI icon does not accept #234, MultistateNumber.error returns a boolean, so the option always reports an error #235 and any found later). - Refactoring, splitting files, or changing MobX annotation maps.
- Changing Renderer bridge behaviour, channels or the preload's exposed methods.
Further Notes
- Glossary: Page, Page store, Renderer bridge, Shell.
- Measured on
masteratb0d2729(MobX 7.1.7, TypeScript 5.9.3, React 19.3.1): plaintscreports 26 diagnostics, all in scope;--noImplicitAnyadds 414 in scope, 267 of them in seven files. Typing the option base alone clears 22 of the 26. - Neither known bug was confirmed by running the app; both verdicts come from reading the code.
- Not verified by the map: what the Vite renderer build emits for a type-only class field, and
mobx-utilstypings against MobX 7. The Jest transform was verified to keep the barevaluefield. - The tracker conventions and coding standards are kept on the maintainer's clone only, so a leaf's edits to them do not appear in its pull request diff.
- Next:
/to-ticketsfor the 17 leaves, then/implementper ticket.
Activity
jtklein-agents commentedon Nov 22, 2026
Merged upstream: AntonelliLab#508
Convert the Page, preload and alignment parsers to TypeScript (Antone…