TanStackT
TanStack3mo ago
13 replies
sacred-rose

How to use a Set in default values?

I am using Select from Hero UI, which uses a Set for its value. But when I do this, the schema validator types do not come out correctly. It seems they are transforming the types to be serializable, converting from Set to Array.

Here's a mini code snippet to reproduce:

import {Schema} from "effect";

export const CreateScheduleInputSchema = Schema.Struct({
    daysOfWeek: Schema.Set(Schema.Enums(DayOfWeek)).pipe(Schema.mutable),
});

const form = useAppForm({
    defaultValues: {
        daysOfWeek: new Set(),
    },
    validators: {
        // The types are wrong here!
        onSubmit: Schema.standardSchemaV1(CreateScheduleInputSchema),
    },
});


Is there something I am missing?
Was this page helpful?