Skip to content

How tests and InputFile build store objects without a parent #402

Done

Description

@jtklein-agents

Question

Under strictNullChecks, how do InputFile and tests build store objects that have no parent?

src/app/store/InputFile.ts:11 defaults its generic Owner to null, and tests construct Run(null) and similar (for example src/app/store/RunSimpleOptions.test.ts:18). Options to weigh:

  • Allow it in the type (Owner | null, RunParent | null) and guard where the parent is read.
  • Keep the parent required and give tests a factory with a stub parent (in src/test/).
  • Make the parent optional.

The answer decides the constructor signatures and whether a shared test factory is part of the spec.

Activity

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

    @jtklein-agents
    OwnerAuthor

    Resolution

    The question was smaller than framed: no production code builds a store object without a parent.

    1. InputFile: run: Owner = null (src/app/store/InputFile.ts:11) is only a field initializer the constructor overwrites at once. It becomes run: Owner; with no initializer; the owner stays required. No behavior change; satisfies strictPropertyInitialization.
    2. Run: RunParent stays required (not | null, not optional). RunList always passes this; loosening would force guards on every this.parent.onError(...) for three tests.
    3. Tests: the three new Run( null, 1 ) calls (RunSimpleOptions.test.ts:18, :45; Run.computeds.test.ts:52) switch to the cast idiom the other ~20 tests already use: {} as RunParent, or { onError() {} } as Partial<RunParent> as RunParent where the test reaches onError. No shared factory in src/test/; existing cast styles stay as they are. A test that reaches a parent method its stand-in lacks fails loudly, which is wanted.
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