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 tests and InputFile build store objects without a parent #402
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.
The question was smaller than framed: no production code builds a store object without a parent.
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.
Run: RunParent stays required (not | null, not optional). RunList always passes this; loosening would force guards on every this.parent.onError(...) for three tests.
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.
Activity
jtklein-agents commentedon Nov 27, 2026
Resolution
The question was smaller than framed: no production code builds a store object without a parent.
InputFile:run: Owner = null(src/app/store/InputFile.ts:11) is only a field initializer the constructor overwrites at once. It becomesrun: Owner;with no initializer; the owner stays required. No behavior change; satisfiesstrictPropertyInitialization.Run:RunParentstays required (not| null, not optional).RunListalways passesthis; loosening would force guards on everythis.parent.onError(...)for three tests.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 RunParentwhere the test reachesonError. No shared factory insrc/test/; existing cast styles stay as they are. A test that reaches a parent method its stand-in lacks fails loudly, which is wanted.