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 option components type setValue under strictFunctionTypes #404
Under strictFunctionTypes, how do the option components type the setValue they receive?
OptionSelect's OptionSelectOptionLike declares setValue: ( value: unknown ) => void (src/app/components/OptionSelect.tsx:20); store options pass ( value: string ) => void, which is no longer assignable. That causes the prop errors at src/app/App.tsx:221, :249, :314, :503 (via InputRun, ModelRun, RaxmlRun, EditorAlignment) and src/app/AlignmentCard.tsx:249. OptionTextField (string) and OptionCheck (boolean) already name their value type.
Options to weigh:
A generic OptionSelectOptionLike<Value> (and matching options/value types), threaded through the prop types that embed it.
Method syntax (setValue( value: unknown ): void), which is bivariant and turns the check off for this member.
Narrow unknown to the union of values selects actually hold.
Facts (scratch compile under --strict): the target setValue: ( value: unknown ) => void is a function-typed property, so strictFunctionTypes rejects the store's ( value: string ) => void. Narrowing unknown to string | number | readonly string[] fails the same way. observer (mobx-react-lite overload observer<C>( c: C ): C & …) keeps a generic component's type parameter. MUI types e.target.value as Value | string (its SelectChangeEvent includes a plain input change event).
Generic.OptionSelectOptionLike<Value extends string | number | readonly string[]>; value: Value, setValue: ( value: Value ) => void. OptionSelect becomes a generic observer component. Its onChange keeps a single e.target.value as Value, with a one-line comment naming MUI's change event union as the reason. Rejected: method syntax (setValue( value: unknown ): void) — compiles with no cast but turns the check off for the member, letting a number option silently receive a string (the class of bug in Part start and end setters receive strings from OptionTextField).
OptionTextField and OptionCheck stay as they are: they already name string/boolean and raise no strict errors.
Every embedding field names its real value type, no default type parameter: for example in ModelRun, RaxmlRun, CardAlignment's ng* fields, EditorAlignment.partition.partToAdd: numThreads/numRuns → <number>, numRepetitions/numRepetitionsNg → <number | string>, outGroup → <string[]>, the rest <string>. A string default would quietly mis-type the number and array options.
Activity
jtklein-agents commentedon Nov 27, 2026
Resolution
Facts (scratch compile under
--strict): the targetsetValue: ( value: unknown ) => voidis a function-typed property, sostrictFunctionTypesrejects the store's( value: string ) => void. Narrowingunknowntostring | number | readonly string[]fails the same way.observer(mobx-react-lite overloadobserver<C>( c: C ): C & …) keeps a generic component's type parameter. MUI typese.target.valueasValue | string(itsSelectChangeEventincludes a plain input change event).OptionSelectOptionLike<Value extends string | number | readonly string[]>;value: Value,setValue: ( value: Value ) => void.OptionSelectbecomes a genericobservercomponent. ItsonChangekeeps a singlee.target.value as Value, with a one-line comment naming MUI's change event union as the reason. Rejected: method syntax (setValue( value: unknown ): void) — compiles with no cast but turns the check off for the member, letting a number option silently receive a string (the class of bug in Part start and end setters receive strings from OptionTextField).OptionTextFieldandOptionCheckstay as they are: they already namestring/booleanand raise no strict errors.ModelRun,RaxmlRun,CardAlignment'sng*fields,EditorAlignment.partition.partToAdd:numThreads/numRuns→<number>,numRepetitions/numRepetitionsNg→<number | string>,outGroup→<string[]>, the rest<string>. Astringdefault would quietly mis-type the number and array options.