Skip to content

[Remote forms][regression] Zod4 enum array does not type correctly when using .as('checkbox') #15722

@dualjack

Description

@dualjack

Describe the bug

Having a simple zod4 object:

(ignore the enumValues, it's just an array of strings)

const setPolicySchema = z.object({
    policyAvailableAccessTypes: z.enum(gateAccessTypeEnum.enumValues).array().default(['unlimited']),
})

When using it on the front-end like that:

<Checkbox {...setGatePolicyForm.fields.policyAvailableAccessTypes.as('checkbox', 'unlimited')}>
    Unlimited
</Checkbox>

it completely loses the definition for .as()

Image

As strange as it is, if we ignore intellisense, the code works and everything renders fine,
so my assumption is: there is a missing type definition for that use.

EDIT:

I dicovered that types works fine, when the .default([]) is missing:

const setPolicySchema = z.object({
    policyAvailableAccessTypes: z.enum(gateAccessTypeEnum.enumValues).array(),
})
Image

EDIT 2:

I also found out this was not a problem in previous versions of svelte, so it is a regression.

Reproduction

I will not waste your time with reproduction repos etc.
because it's working fine, but is propably typed incorrectly.

System Info

"svelte": "5.55.4",
"@sveltejs/kit": "2.57.1",
"zod": "^4.1.13",

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions