Skip to content

Typed <option> elements #3

Open
@CodeStix

Description

@CodeStix

When using a FormSelect, its name field is type checked, but its options are not.

type FormData = {
    enum: "option1" | "option2" | "option3";
};
const form = useForm({ enum: "option1" } as FormData);
// ...
<FormSelect form={form} name="enum">
    <option value="option1">Option 1</option>
    <option value="option2">Option 2</option>
    <option value="option3">Option 3</option>
    {/* Next line does not show error, but option4 is invalid! */}
    <option value="option4">Option 4</option>
</FormSelect>;

This should be possible to typecheck by only accepting children of a specific type in FormSelect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions