You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How Alignment and Run represent data that isn't parsed yet #401
Under strictNullChecks, how should Alignment and Run represent data that is not parsed or chosen yet?
Today fields filled in after loading are typed as possibly undefined (for example Alignment.dataType, the values read at src/app/store/Alignment.ts:218, :301, :324–:353, :407–:426; Run.analysis at src/app/store/Run.ts:210; Option defaults at src/app/store/Option.ts:43; PartOptions at src/app/store/PartOptions.ts:159). That makes Alignment not assignable to AlignmentLike/PartitionAlignment (Alignment.ts:135–141) and Run not assignable to the component prop types (InputRun, CardFinalAlignment), giving the App.tsx and AlignmentCard.tsx overload errors.
Options to weigh:
Keep the fields optional and narrow where they're used; loosen the prop types to match.
Give them non-optional defaults so the store types tighten and the prop types stay.
Split loading and loaded types (for example a parsed-alignment type only cards receive).
The answer decides which of the store types and the prop types change, and whether any undefined reaching the UI today is a real bug to file separately.
Main/common boundary tightens.typecheckAlignment returns a typechecked-alignment type with dataType, numSequences, fileFormat, hasInvariantSites, typecheckingComplete required; AlignmentParseResult carries it. Today's code already guarantees these once io.parseAlignment resolves. The store copies them in loadParsedAlignment without narrowing (clears Alignment.ts:407–426).
Store keeps "not parsed yet" as undefined.Alignment.dataType, fileFormat, convertedFrom (and similar late-set fields) stay | undefined. The copies that claim string widen to DataType | undefined / string | undefined: AlignmentLike in AlignmentOptions.ts and PartOptions.ts, PartitionAlignment in Partition.ts, and the Run.dataType getter. Readers narrow (for example runModelTest guards on modelTestCanRun). Rejected: defaulting to 'unknown' (already means all-unknown characters; would stop getFinalDataType skipping it) and a split loaded-alignment type (large refactor of an in-place MobX class).
Lookups that can't miss (Run.analysisOption's find at Run.ts:210, test()-then-exec()[0] in setModelFromString) throw a plain Error naming the missing value, or become a single match with a guard. No !.
Activity
jtklein-agents commentedon Nov 27, 2026
Resolution
typecheckAlignmentreturns a typechecked-alignment type withdataType,numSequences,fileFormat,hasInvariantSites,typecheckingCompleterequired;AlignmentParseResultcarries it. Today's code already guarantees these onceio.parseAlignmentresolves. The store copies them inloadParsedAlignmentwithout narrowing (clearsAlignment.ts:407–426).undefined.Alignment.dataType,fileFormat,convertedFrom(and similar late-set fields) stay| undefined. The copies that claimstringwiden toDataType | undefined/string | undefined:AlignmentLikeinAlignmentOptions.tsandPartOptions.ts,PartitionAlignmentinPartition.ts, and theRun.dataTypegetter. Readers narrow (for examplerunModelTestguards onmodelTestCanRun). Rejected: defaulting to'unknown'(already means all-unknown characters; would stopgetFinalDataTypeskipping it) and a split loaded-alignment type (large refactor of an in-place MobX class).Run.analysisOption'sfindatRun.ts:210,test()-then-exec()[0]insetModelFromString) throw a plainErrornaming the missing value, or become a singlematchwith a guard. No!.aaMatrixName'sre.exec( model )[1](Alignment.ts:353) can genuinely miss; filed as Applying a modeltest result with an unlisted protein matrix throws a TypeError, not fixed here.Correction: the
App.tsx/AlignmentCard.tsxprop errors arestrictFunctionTypes(setValuevariance), not unparsed data; moved to How option components type setValue under strictFunctionTypes.