Skip to content

Turn on strictFunctionTypes - #411

Merged
jtklein-agents merged 1 commit into
spec/406-strict-typescriptfrom
407-turn-on-strictfunctiontypes
Nov 27, 2026
Merged

jtklein-agents merged 1 commit into
spec/406-strict-typescriptfrom
407-turn-on-strictfunctiontypes

Conversation

@jtklein-agents

Copy link
Copy Markdown
Owner

Closes #407

Summary

tsconfig.json turns on strictFunctionTypes. Fixes for what it flags:

 OptionSelect (src/app/components/OptionSelect.tsx)
-  OptionSelectOptionLike            setValue( value: unknown )
+  OptionSelectOptionLike<Value>     setValue( value: Value )
+  onChange: setValue( e.target.value as Value )   // MUI types it Value | string
-  observer( function OptionSelect … )
+  observer<typeof OptionSelect>( OptionSelect )   // stays generic

 ModelRun / RaxmlRun / CardAlignment / EditorAlignment.partToAdd
+  numRuns, numThreads                <number>
+  numRepetitions, numRepetitionsNg   <number | string>
+  outGroup                           <string[]>
+  the rest                           <string>

 ipcMain.handle( RUN_START | ASTRAL_REQUEST | ALIGNMENT_MODEL_SELECTION_REQUEST, … )
-  startRun / runAstral / runModelSelection / send / runProcess ( event: IpcMainEvent )
+  … ( event: IpcMainInvokeEvent )

 rendererBridge.onUnhandledError
-  ( listener: ( payload: unknown ) => void )
+  ( listener: ( payload: UnhandledErrorPayload ) => void )   // RunList listener, no cast
+  main's UNHANDLED_ERROR send `satisfies UnhandledErrorPayload`

One mismatch the ticket did not list (it was hidden behind the first OptionSelect error): part start and end are number options, but OptionTextField hands them the field's text, which the yup number schema casts. Option gains an Input type parameter, so only the type changes:

-class Option<Value = unknown, Owner = unknown> {
-  setValue( value: Value )
+class Option<Value = unknown, Owner = unknown, Input = Value> {
+  setValue( value: Input )
-class PartStart extends PartBase<number>
+class PartStart extends PartBase<number, number | string>   // PartEnd too

OptionTextField and OptionCheck are unchanged. No setValue becomes method syntax.

Evidence

  • Before: with the flag on, yarn typecheck fails:
    src/app/AlignmentCard.tsx(249,23): error TS2769: No overload matches this call.
    src/app/App.tsx(221|249|314|503,…): error TS2769: No overload matches this call.
    src/app/store/RunList.ts(100,49): error TS2345: … not assignable to parameter of type 'Listener'.
    src/main/api.ts(126|193|194,…): error TS2345: (event: IpcMainEvent, …) not assignable to (event: IpcMainInvokeEvent, …)
    
    Part.test.ts used @ts-expect-error to pass '7' and 'abc' to start.setValue.
    After: yarn verify passes: lint, typecheck, and 72 test files / 497 tests. Part.test.ts passes those strings with no directive.

Merge Danger

Door: two-way

Types only, apart from one added satisfies. Rolling back is a revert.

Blast Radius: typecheck

Nothing changes at runtime. PartStart.value and PartEnd.value are still typed number while they hold the raw text of an invalid input such as 'abc'. That was already true before this change; the cast in Option.setValue now says so in a comment.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@jtklein-agents
jtklein-agents merged commit 9030dde into spec/406-strict-typescript Nov 27, 2026
4 checks passed
@jtklein-agents
jtklein-agents deleted the 407-turn-on-strictfunctiontypes branch November 27, 2026 14:45
@jtklein-agents jtklein-agents mentioned this pull request Nov 27, 2026
9 tasks
jtklein-agents added a commit that referenced this pull request Nov 27, 2026
* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

* Type the parse result and store models under strictNullChecks (#413)

typecheckAlignment returns a TypecheckedAlignment with dataType,
numSequences, fileFormat, hasInvariantSites and typecheckingComplete
required, and AlignmentParseResult carries it. Store fields that stay
undefined until load widen their readers' types; lookups that cannot
miss throw a plain Error. strict tsc: 149 -> 118 errors, none in the
touched non-test files.

Refs #408

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Turn on strict mode and type-check the tests under it (#410)

tsconfig sets "strict": true and drops the flags it implies. Test files
use `!` where a lookup is known to hit; the null-parent Runs use
`{} as RunParent`. Strict surfaced a clash between the store's optional
hoverInfo and the option components' required one, and Input's
astralTree prop; both are loosened to match the store, with no runtime
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant