From 762410460ae9b39573335a9881b4ef503973a86a Mon Sep 17 00:00:00 2001 From: Johannes Klein Agents Date: Tue, 17 Nov 2026 15:20:07 +0100 Subject: [PATCH 1/2] Rename the app shell to TypeScript Co-Authored-By: Claude Opus 5.5 --- scripts/typecheck-baseline.txt | 4 ++-- src/app/{App.js => App.tsx} | 0 src/app/components/{ErrorDialog.js => ErrorDialog.tsx} | 0 src/app/{index.js => index.tsx} | 0 src/pageNodeImports.test.js | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename src/app/{App.js => App.tsx} (100%) rename src/app/components/{ErrorDialog.js => ErrorDialog.tsx} (100%) rename src/app/{index.js => index.tsx} (100%) diff --git a/scripts/typecheck-baseline.txt b/scripts/typecheck-baseline.txt index 5f0f0037..390d4581 100644 --- a/scripts/typecheck-baseline.txt +++ b/scripts/typecheck-baseline.txt @@ -1,4 +1,4 @@ -src/app/App.js(466,12): error TS2739: Type '{ error: ErrorObject; onClose: () => void; }' is missing the following properties from type '{ error: any; onClose: any; needReload: any; title: any; }': needReload, title -src/app/App.js(512,10): error TS2741: Property 'needReload' is missing in type '{ error: unknown; title: string; onClose: () => void; }' but required in type '{ error: any; onClose: any; needReload: any; title: any; }'. +src/app/App.tsx(466,12): error TS2739: Type '{ error: ErrorObject; onClose: () => void; }' is missing the following properties from type '{ error: any; onClose: any; needReload: any; title: any; }': needReload, title +src/app/App.tsx(512,10): error TS2741: Property 'needReload' is missing in type '{ error: unknown; title: string; onClose: () => void; }' but required in type '{ error: any; onClose: any; needReload: any; title: any; }'. src/app/App.test.js(5,1): error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`. src/app/App.test.js(13,3): error TS2304: Cannot find name 'expect'. diff --git a/src/app/App.js b/src/app/App.tsx similarity index 100% rename from src/app/App.js rename to src/app/App.tsx diff --git a/src/app/components/ErrorDialog.js b/src/app/components/ErrorDialog.tsx similarity index 100% rename from src/app/components/ErrorDialog.js rename to src/app/components/ErrorDialog.tsx diff --git a/src/app/index.js b/src/app/index.tsx similarity index 100% rename from src/app/index.js rename to src/app/index.tsx diff --git a/src/pageNodeImports.test.js b/src/pageNodeImports.test.js index 37a3aeb0..c3930c98 100644 --- a/src/pageNodeImports.test.js +++ b/src/pageNodeImports.test.js @@ -44,6 +44,6 @@ it( 'the page can still import the user-fix error type and the alignment typeche expect( alignment ).toMatch( /from ['"]\.\.\/\.\.\/common\/typecheckAlignment['"]/ ); expect( alignment ).toMatch( /from ['"]\.\.\/\.\.\/common\/errors['"]/ ); expect( run ).toMatch( /from ['"]\.\.\/\.\.\/common\/errors['"]/ ); - expect( fs.readFileSync( path.join( __dirname, 'app', 'index.js' ), 'utf8' ) ) + expect( fs.readFileSync( path.join( __dirname, 'app', 'index.tsx' ), 'utf8' ) ) .not.toMatch( /from ['"]\.\.\/common\/utils['"]/ ); } ); From f25db54b4f5484805e3cfe5bdef284f5e49efd41 Mon Sep 17 00:00:00 2001 From: Johannes Klein Agents Date: Tue, 17 Nov 2026 15:23:05 +0100 Subject: [PATCH 2/2] Type the app shell The error dialog, the app and the page entry gain explicit types; the error dialog's propTypes and the direct prop-types dependency go. The typecheck baseline is now empty. Input's run type reuses the card props it passes on, so the real Run checks against it. Two card fields the store does not have are widened to optional: the tree's loading flag (never set) and the final alignment's numSequencesParsed (parsing is always complete there). Co-Authored-By: Claude Opus 5.5 --- package.json | 1 - scripts/typecheck-baseline.txt | 4 ---- src/app/AlignmentCard.tsx | 3 ++- src/app/App.test.js | 1 + src/app/App.tsx | 21 +++++++++++++++++---- src/app/Input.tsx | 19 ++++++++++++------- src/app/TreeCard.tsx | 3 ++- src/app/components/ErrorDialog.tsx | 30 +++++++++++++++++++----------- src/app/index.tsx | 2 +- 9 files changed, 54 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 045d9eba..d4c62b1e 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,6 @@ "postinstall-postinstall": "^2.1.0", "prismjs": "^1.30.0", "prismjs-bibtex": "^2.1.0", - "prop-types": "^15.8.1", "react": "^19.3.1", "react-dom": "^19.3.1", "react-dropzone": "^20.2.0", diff --git a/scripts/typecheck-baseline.txt b/scripts/typecheck-baseline.txt index 390d4581..e69de29b 100644 --- a/scripts/typecheck-baseline.txt +++ b/scripts/typecheck-baseline.txt @@ -1,4 +0,0 @@ -src/app/App.tsx(466,12): error TS2739: Type '{ error: ErrorObject; onClose: () => void; }' is missing the following properties from type '{ error: any; onClose: any; needReload: any; title: any; }': needReload, title -src/app/App.tsx(512,10): error TS2741: Property 'needReload' is missing in type '{ error: unknown; title: string; onClose: () => void; }' but required in type '{ error: any; onClose: any; needReload: any; title: any; }'. -src/app/App.test.js(5,1): error TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`. -src/app/App.test.js(13,3): error TS2304: Cannot find name 'expect'. diff --git a/src/app/AlignmentCard.tsx b/src/app/AlignmentCard.tsx index 166d3bb9..1dbb18bd 100644 --- a/src/app/AlignmentCard.tsx +++ b/src/app/AlignmentCard.tsx @@ -62,7 +62,8 @@ interface CardAlignment { interface CardFinalAlignment { dataType?: string; numSequences: number; - numSequencesParsed: number; + // Absent on the store FinalAlignment; its parsingComplete is always true. + numSequencesParsed?: number; length: number; numAlignments: number; filename: string; diff --git a/src/app/App.test.js b/src/app/App.test.js index 431e6449..380f08bf 100644 --- a/src/app/App.test.js +++ b/src/app/App.test.js @@ -1,3 +1,4 @@ +// @ts-nocheck — Jest globals. checkJs has no test runner types. import React, { act } from 'react'; import { createRoot } from 'react-dom/client'; import Page from './index'; diff --git a/src/app/App.tsx b/src/app/App.tsx index 293e452f..ef2bae47 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -34,7 +34,7 @@ import ErrorBoundary from './components/ErrorBoundary'; import ErrorDialog from './components/ErrorDialog'; import ModifiedDialog from './components/ModifiedDialog'; -const VerticalHeading = styled( Typography )( ( { theme } ) => ( { +const VerticalHeading = styled( Typography )( () => ( { writingMode: 'vertical-rl', textOrientation: 'upright', padding: '10px 5px', @@ -43,7 +43,20 @@ const VerticalHeading = styled( Typography )( ( { theme } ) => ( { borderRight: '1px solid #ccc', } ) ); -const App = () => { +interface SnackRun { + converted: boolean; + convertedAlignmentFrom: string | null; + modified: boolean; + showModifiedSnack: boolean; + clearShowModified: () => void; +} + +interface SnackStore { + showAppSnack: boolean; + clearAppSnack: () => void; +} + +const App = (): React.JSX.Element => { const TabItems = store.runs.map( ( run ) => ( { /> ) ); - function fileModifiedSnack( run ) { + function fileModifiedSnack( run: SnackRun ): React.JSX.Element { let message = 'Something happened'; if ( run.converted ) { message = `Converted your ${run.convertedAlignmentFrom} alignment into fasta!`; @@ -107,7 +120,7 @@ const App = () => { ); } - function appSnack( store ) { + function appSnack( store: SnackStore ): React.JSX.Element { const message = 'Command copied'; return ( void; addPartitionFiles: ( files: DroppedFile[] ) => void; addTreeFiles: ( type: string, files: DroppedFile[] ) => void; addAstralFiles: ( file: DroppedFile ) => void; inputIsAlignment: boolean; - alignments: { path: string }[]; + alignments: ( AlignmentCardProps['alignment'] & { path: string } )[]; inputIsTree: boolean; - astralTree: unknown; + astralTree: AstralTreeCardProps['astralTree']; canLoadAlignment: boolean; haveAlignments: boolean; canLoadPartitionFile: boolean; @@ -42,8 +47,8 @@ interface InputRun { loadBackboneConstraintFile: () => void; multifurcatingConstraint: InputTree; loadMultifurcatingConstraintFile: () => void; - finalAlignment: unknown; -} + finalAlignment: FinalAlignmentCardProps['alignment']; +}; export interface InputProps { run: InputRun; diff --git a/src/app/TreeCard.tsx b/src/app/TreeCard.tsx index a111c025..95e6e68b 100644 --- a/src/app/TreeCard.tsx +++ b/src/app/TreeCard.tsx @@ -14,7 +14,8 @@ import type { SxProps, Theme } from '@mui/material/styles'; interface CardTree { name: string; - loading: boolean; + // The store Tree has no loading flag, so this always reads undefined. + loading?: boolean; openFile: () => void; openFolder: () => void; remove: () => void; diff --git a/src/app/components/ErrorDialog.tsx b/src/app/components/ErrorDialog.tsx index 53034be8..2c817c06 100644 --- a/src/app/components/ErrorDialog.tsx +++ b/src/app/components/ErrorDialog.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import { Box } from '@mui/material'; import Dialog from '@mui/material/Dialog'; import DialogTitle from '@mui/material/DialogTitle'; @@ -17,11 +16,27 @@ import { getMailtoLinkToReportError } from '../report'; import { reportIssueToGitHub } from '../githubIssue'; const handleReload = () => { - const { rendererBridge } = /** @type {any} */ ( window ); - return rendererBridge.reload(); + return window.rendererBridge.reload(); }; -export default function ErrorDialog( { error, onClose, needReload, title } ) { +type DialogError = Error & { isUserFix?: boolean }; + +export interface ErrorDialogProps { + // Store errors are caught values (unknown) or serialized bridge errors. + error?: unknown; + onClose: () => void; + needReload?: boolean; + title?: string | null; +} + +export default function ErrorDialog( { + error: caught, + onClose, + needReload, + title, +}: ErrorDialogProps ): React.JSX.Element | null { + // The dialog reads name, message and isUserFix as the untyped component did. + const error = caught as DialogError | null | undefined; const [reported, setReported] = React.useState( false ); const mailtoContent = React.useMemo( () => ( error @@ -171,10 +186,3 @@ export default function ErrorDialog( { error, onClose, needReload, title } ) { return returnDialog; } - -ErrorDialog.propTypes = { - error: PropTypes.object, - onClose: PropTypes.func.isRequired, - needReload: PropTypes.bool, - title: PropTypes.string, -}; diff --git a/src/app/index.tsx b/src/app/index.tsx index 836d07db..efbd31d3 100644 --- a/src/app/index.tsx +++ b/src/app/index.tsx @@ -16,7 +16,7 @@ if ( process.env.NODE_ENV !== 'development' ) { } ); } -const Index = () => { +const Index = (): React.JSX.Element => { const { light, dark } = theme; const muiTheme = store.config.isDarkMode ? dark