T
TanStack12mo ago
metropolitan-bronze

Array field get inferred as type never[]

When passing the empty array as a default value to an array field, it gets inferred as never[] instead of the type inferred from zod schema. And in general, it gets inferred as the type of whatever I pass to default value. Is this intended behavior?
3 Replies
foreign-sapphire
foreign-sapphire12mo ago
Open a bug and please include a minimal reproduction and we'll take a look
metropolitan-bronze
metropolitan-bronzeOP12mo ago
just to make sure, since I think this is a part of a larger issue - the types don't get inferred from zod schema at all, since if I remove the type cast in default values I can pass anything I want and it will be inferred as the type of that object instead of the zod schema shape
metropolitan-bronze
metropolitan-bronzeOP12mo ago
GitHub
Form field types don't get inferred from zod schema · Issue #1066 ·...
Describe the bug Without type casting the default values, the form type gets inferred as ReactFormExtendedApi<TYPE, Validator<unknown, z.ZodType<any, z.ZodTypeDef, any>>> where TY...

Did you find this page helpful?