Skip to content

How Alignment and Run represent data that isn't parsed yet #401

Done

Description

@jtklein-agents

Question

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.

Activity

  1. added
    wayfinder:grilling
    on Nov 27, 2026
  2. jtklein-agents commented on Nov 27, 2026

    @jtklein-agents
    OwnerAuthor

    Resolution

    1. 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).
    2. 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).
    3. 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 !.
    4. aaMatrixName's re.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.tsx prop errors are strictFunctionTypes (setValue variance), not unparsed data; moved to How option components type setValue under strictFunctionTypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

wayfinder:grilling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions