Skip to content

Typed <option> elements #3

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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