Skip to content

Parse result and store models under strictNullChecks - #413

Merged
jtklein-agents merged 1 commit into
spec/406-strict-typescriptfrom
408-parse-result-and-store-models-under-strictnullchecks
Nov 27, 2026
Merged

jtklein-agents merged 1 commit into
spec/406-strict-typescriptfrom
408-parse-result-and-store-models-under-strictnullchecks

Conversation

@jtklein-agents

Copy link
Copy Markdown
Owner

Closes #408

Summary

The parse result has its fields set, and the store models now pass strictNullChecks. The flag itself is still off.

 io.parseAlignment(filePath): Promise<
-  { sequences, length }
+  TypecheckedAlignment   // dataType, numSequences, fileFormat,
+                         // hasInvariantSites, typecheckingComplete required
 >
 Alignment.loadParsedAlignment
-  newDataType = getFinalDataType(list)                // DataType | undefined
+  newDataType = getFinalDataType([...others, parsed]) // overload: DataType
   copy fields                                         // no narrowing

Alignment.dataType, fileFormat and convertedFrom keep undefined until the alignment loads. The types that copy dataType now allow undefined too: AlignmentLike (in both files), PartitionAlignment, AlignmentOwner, RunOwner, and Run.dataType (which returns DataType | undefined). Code that reads them checks for undefined first.

Lookups that can't miss (Run.analysisOption and the setModelFromString regexes) now throw a plain Error that names the missing value, or use one match with a guard. The only ! in production code is the protein matrix exec. It has a comment, and its behaviour is unchanged because #403 owns that case.

Behaviour changes, all in states that should not happen:

Where Before After
typecheckAlignment: no sequence matches a data type (e.g. only T and -) loads with dataType undefined rejects with a UserFixError
runModelTest: no modeltest binary in the binaries list sends binaryName: undefined to the main process throws before starting
runModelTest: modelTestCanRun is false starts model selection returns
astralArgs: no ASTRAL tree -i undefined -i left out
partitionType / getPartitionType before the alignment is parsed undefined ''
Part type options before the alignment is parsed [{ value: undefined }] []

Evidence

  • Before: tsc --noEmit -p tsconfig.json --strict → 149 errors, 31 of them in the files this PR touches:

    Alignment.ts(324): Object is possibly 'null'        // /\+F/.exec(raxmlNG)[0]
    Run.ts(210): 'AnalysisChoice | undefined' → 'AnalysisChoice'
    InputFile.ts(11): 'null' → 'Owner'
    StoreBase.ts(43): Cannot invoke an object which is possibly 'undefined'
    …
    

    After: 118 errors, 0 in the non-test files this PR touches. App.tsx still has its 4 pre-existing strictFunctionTypes errors, and this PR does not touch it.

  • Before: an alignment whose sequences match no data type loads with dataType undefined.
    After: src/common/typecheckAlignment.test.ts passes:

    typecheckAlignment(['TT-T', '----'])
      → throws "cannot determine data type of any of the 2 sequences"
    
  • yarn lint, yarn typecheck and yarn test all pass (73 files, 499 tests).

Merge Danger

Door: two-way

The change is mostly types. A revert restores the old behaviour.

Blast Radius: alignment-loading

An alignment whose sequences match no data type now fails to load with an error, where before it loaded with no data type. Every other behaviour change is in a state that a parsed alignment or a configured binaries list rules out.

🤖 Generated with Claude Code

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>
@jtklein-agents
jtklein-agents merged commit 2d38081 into spec/406-strict-typescript Nov 27, 2026
6 of 7 checks passed
@jtklein-agents
jtklein-agents deleted the 408-parse-result-and-store-models-under-strictnullchecks branch November 27, 2026 15:00
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