From 39660dc7614f4528a6a7946b6569d6a625a209cb Mon Sep 17 00:00:00 2001 From: Johannes Klein Agents Date: Fri, 27 Nov 2026 14:29:59 +0100 Subject: [PATCH 1/4] Type-check main process and app files under strictNullChecks (#409) processHelpers optional-chains the stdout/stderr pipes, modelSelection throws explicitly on a missing best-model match (same catch, same user message), paths falls back on pop(), bootstrap spreads instead of [].concat. --strict errors: 149 -> 142, zero in these files. Co-Authored-By: Claude Opus 5.5 --- src/app/bootstrap.ts | 2 +- src/app/paths.ts | 3 ++- src/main/modelSelection.ts | 7 +++++-- src/main/processHelpers.ts | 5 +++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/bootstrap.ts b/src/app/bootstrap.ts index e6ed79b2..4cbe2737 100644 --- a/src/app/bootstrap.ts +++ b/src/app/bootstrap.ts @@ -50,7 +50,7 @@ function initDev( exampleFiles: ExampleFilesPayload ): void { ].map( ( filename ) => ( { path: join( exampleFilesDir, 'phylip', filename ), } ) ); - const useFiles = [].concat( useFastaFiles, usePhylipFiles ); + const useFiles = [ ...useFastaFiles, ...usePhylipFiles ]; store.activeRun.addAlignments( useFiles ); store.activeRun.setOutputDir( exampleFiles.outdir ); setTimeout( () => { diff --git a/src/app/paths.ts b/src/app/paths.ts index 75abd603..b6e25111 100644 --- a/src/app/paths.ts +++ b/src/app/paths.ts @@ -12,7 +12,8 @@ const stemOf = ( baseName: string ): string => { const parsed = ( filePath: string ): { base: string; name: string; dir: string } => { const sep = sepOf( filePath ); const chunks = filePath.split( /[/\\]/ ); - const baseName = chunks.pop(); + // split() always returns at least one chunk, so pop() never yields undefined. + const baseName = chunks.pop() ?? ''; let directory = ''; if ( chunks.length === 1 && chunks[0] === '' ) { directory = sep; diff --git a/src/main/modelSelection.ts b/src/main/modelSelection.ts index 7ef2f94e..a463be17 100644 --- a/src/main/modelSelection.ts +++ b/src/main/modelSelection.ts @@ -119,9 +119,12 @@ export async function runModelSelection( // Each '> [program]' is written three times, for BIC, AIC and AICc respectively. Use AICc. const cmdRaxml = commands.filter( ( cmd ) => cmd.startsWith( ' > raxmlHPC-SSE3' ) )[2]; const cmdRaxmlNG = commands.filter( ( cmd ) => cmd.startsWith( ' > raxml-ng' ) )[2]; - const modelRaxml = /-m (\S+)/.exec( cmdRaxml )[1]; + const modelRaxml = /-m (\S+)/.exec( cmdRaxml )?.[1]; const extraFlag = /--(\S+)/.exec( cmdRaxml )?.[0]; - const modelRaxmlNG = /--model (\S+)/.exec( cmdRaxmlNG )[1]; + const modelRaxmlNG = /--model (\S+)/.exec( cmdRaxmlNG )?.[1]; + if ( !modelRaxml || !modelRaxmlNG ) { + throw new Error( 'No best-model command in modeltest-ng output' ); + } console.log( `-> raxml: ${modelRaxml}, extraFlag: ${extraFlag}, raxml-ng: ${modelRaxmlNG}` ); send( event, ipc.ALIGNMENT_MODEL_SELECTION_SUCCESS, { id, diff --git a/src/main/processHelpers.ts b/src/main/processHelpers.ts index fee48079..a7ec9034 100644 --- a/src/main/processHelpers.ts +++ b/src/main/processHelpers.ts @@ -103,14 +103,15 @@ export async function runProcess( let exited = false; // Last stdout only: the binary prints its fatal reason just before exiting. let stdoutTail = ''; - proc.stdout.on( 'data', ( buffer: string | Buffer ) => { + // execFile always opens stdout and stderr pipes; the optional chain only satisfies their nullable type. + proc.stdout?.on( 'data', ( buffer: string | Buffer ) => { const content = String( buffer ); stdoutTail = ( stdoutTail + content ).slice( -8192 ); console.log( 'on stdout:', content ); onStdOut( content ); send( event, ipc.RUN_STDOUT, { id, content } ); } ); - proc.stderr.on( 'data', ( buffer: string | Buffer ) => { + proc.stderr?.on( 'data', ( buffer: string | Buffer ) => { const content = String( buffer ); console.error( 'on stderr:', content ); onStdErr( content ); From 9030dde656f7674aabd0a5e15beb657afd6d0a9a Mon Sep 17 00:00:00 2001 From: jtklein-agents Date: Fri, 27 Nov 2026 15:45:46 +0100 Subject: [PATCH 2/4] Turn on strictFunctionTypes (#411) OptionSelect is generic over its value type, and every prop type that embeds it names the real type. Handlers registered with ipcMain.handle take IpcMainInvokeEvent. The unhandled-error bridge event has a typed payload. Option gains an Input type parameter so part start and end accept the text OptionTextField hands them. Closes #407 Co-authored-by: Claude Opus 5.5 --- src/app/AlignmentCard.tsx | 10 +++++----- src/app/Model.tsx | 24 ++++++++++++------------ src/app/PartitionEditor.tsx | 6 +++--- src/app/Raxml.tsx | 4 ++-- src/app/components/OptionSelect.tsx | 21 +++++++++++---------- src/app/store/Option.ts | 9 +++++---- src/app/store/Part.test.ts | 4 ++-- src/app/store/PartOptions.ts | 7 ++++--- src/app/store/RunList.ts | 4 ++-- src/app/unhandledError.test.tsx | 3 ++- src/common/rendererBridge.ts | 8 +++++++- src/main/api.ts | 3 ++- src/main/astral.ts | 4 ++-- src/main/modelSelection.test.ts | 4 ++-- src/main/modelSelection.ts | 4 ++-- src/main/processHelpers.test.ts | 4 ++-- src/main/processHelpers.ts | 6 +++--- src/main/startRun.ts | 4 ++-- src/preload/index.ts | 4 ++-- tsconfig.json | 1 + 20 files changed, 73 insertions(+), 61 deletions(-) diff --git a/src/app/AlignmentCard.tsx b/src/app/AlignmentCard.tsx index 9a408704..f2aa8cb6 100644 --- a/src/app/AlignmentCard.tsx +++ b/src/app/AlignmentCard.tsx @@ -44,12 +44,12 @@ interface CardAlignment { loading: boolean; showPartition: boolean; partition: { isComplete: boolean }; - substitutionModel: OptionSelectOptionLike; + substitutionModel: OptionSelectOptionLike; multistateNumber: OptionTextFieldOptionLike; - ngStationaryFrequencies: OptionSelectOptionLike; - ngInvariantSites: OptionSelectOptionLike; - ngRateHeterogeneity: OptionSelectOptionLike; - ngAscertainmentBias: OptionSelectOptionLike; + ngStationaryFrequencies: OptionSelectOptionLike; + ngInvariantSites: OptionSelectOptionLike; + ngRateHeterogeneity: OptionSelectOptionLike; + ngAscertainmentBias: OptionSelectOptionLike; modelExtra: CardModelExtra | null; modelTestCanRun: boolean; modeltestLoading: boolean; diff --git a/src/app/Model.tsx b/src/app/Model.tsx index 1c8c7394..b31f2487 100644 --- a/src/app/Model.tsx +++ b/src/app/Model.tsx @@ -11,25 +11,25 @@ import type { OptionCheckOptionLike } from './components/OptionCheck'; interface ModelRun { usesModeltestNg: boolean; usesAstral: boolean; - analysis: OptionSelectOptionLike; - numRuns: OptionSelectOptionLike; - numRepetitions: OptionSelectOptionLike; - numRepetitionsNg: OptionSelectOptionLike; + analysis: OptionSelectOptionLike; + numRuns: OptionSelectOptionLike; + numRepetitions: OptionSelectOptionLike; + numRepetitionsNg: OptionSelectOptionLike; branchLength: OptionCheckOptionLike; sHlike: OptionCheckOptionLike; combinedOutput: OptionCheckOptionLike; - startingTree: OptionSelectOptionLike; - outGroup: OptionSelectOptionLike; + startingTree: OptionSelectOptionLike; + outGroup: OptionSelectOptionLike; haveRandomSeed: boolean; randomSeed: number; setRandomSeed: ( value: string ) => void; - substitutionMatrix: OptionSelectOptionLike; - substitutionRate: OptionSelectOptionLike; - substitutionI: OptionSelectOptionLike; - substitutionAscertainment: OptionSelectOptionLike; - multistateModel: OptionSelectOptionLike; + substitutionMatrix: OptionSelectOptionLike; + substitutionRate: OptionSelectOptionLike; + substitutionI: OptionSelectOptionLike; + substitutionAscertainment: OptionSelectOptionLike; + multistateModel: OptionSelectOptionLike; estimatedFrequencies: OptionCheckOptionLike; - baseFrequencies: OptionSelectOptionLike; + baseFrequencies: OptionSelectOptionLike; } export interface ModelProps { diff --git a/src/app/PartitionEditor.tsx b/src/app/PartitionEditor.tsx index 9972e8be..83ace638 100644 --- a/src/app/PartitionEditor.tsx +++ b/src/app/PartitionEditor.tsx @@ -21,12 +21,12 @@ interface PartPositionOption extends Omit interface EditorPartition { partToAdd: { - type: OptionSelectOptionLike; - aaType: OptionSelectOptionLike; + type: OptionSelectOptionLike; + aaType: OptionSelectOptionLike; name: OptionTextFieldOptionLike; start: PartPositionOption; end: PartPositionOption; - codon: OptionSelectOptionLike; + codon: OptionSelectOptionLike; }; progress: number; currentEndValue: number; diff --git a/src/app/Raxml.tsx b/src/app/Raxml.tsx index cc2a4682..17453924 100644 --- a/src/app/Raxml.tsx +++ b/src/app/Raxml.tsx @@ -12,8 +12,8 @@ import { FormHelperText } from '@mui/material'; interface RaxmlRun { command: string; - binary: OptionSelectOptionLike; - numThreads: OptionSelectOptionLike; + binary: OptionSelectOptionLike; + numThreads: OptionSelectOptionLike; modelTestIsRunningOnAlignment: boolean; cancelModeltestOnAlignment: () => void; running: boolean; diff --git a/src/app/components/OptionSelect.tsx b/src/app/components/OptionSelect.tsx index 71fd069f..2b4235ee 100644 --- a/src/app/components/OptionSelect.tsx +++ b/src/app/components/OptionSelect.tsx @@ -11,27 +11,27 @@ export interface OptionSelectChoice { title: string | number; } -export interface OptionSelectOptionLike { +export interface OptionSelectOptionLike { notAvailable?: boolean; title: string; hoverInfo: string; options: readonly OptionSelectChoice[]; - value: string | number | readonly string[]; - setValue: ( value: unknown ) => void; + value: Value; + setValue: ( value: Value ) => void; multiple?: boolean; error: unknown; placeholder?: string; } -export interface OptionSelectProps { - option: OptionSelectOptionLike; +export interface OptionSelectProps { + option: OptionSelectOptionLike; sx?: SxProps; } -const OptionSelect = observer( function OptionSelect( { +function OptionSelect( { option, sx, -}: OptionSelectProps ) { +}: OptionSelectProps ) { if ( option.notAvailable || option.options.length === 0 ) { return null; } @@ -59,7 +59,8 @@ const OptionSelect = observer( function OptionSelect( {