Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subfield types set to unknown #1295

Open
Oudwins opened this issue Mar 17, 2025 · 0 comments
Open

Subfield types set to unknown #1295

Oudwins opened this issue Mar 17, 2025 · 0 comments

Comments

@Oudwins
Copy link

Oudwins commented Mar 17, 2025

Describe the bug

This is a typescript typing bug that was not present in 0.42.0 (I'm unaware of when it was introduced as I just upgraded to v1 from that version).

It causes some subfields's type to be "unknown". To encounter it you must have a structure that causes the field name to be something like this: prop1.array[${idx].prop

This does only seem to happen when the array and/or parent object in the zod schema is set to optional. But there are some reports of user's having a similar issue even when the parent array or object are not optional (https://discord.com/channels/719702312431386674/1100436934205124660/threads/1349742197788119052)

edit: some other users are saying that the issue happens when using null or optional on arrays

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-uqugutkr?file=package.json,src%2Ffeatures%2Fpeople%2Fshared-form.tsx,src%2Ffeatures%2Fpeople%2Fpage.tsx&preset=node

Steps to reproduce

  1. go to page.tsx in the example
  2. Find the form.Field with name invoice.items[${0}].isPhysical
  3. See the error

Expected behavior

I expect the type in the field.state.value to be correct

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • Chrome
  • Linux

TanStack Form adapter

None

TanStack Form version

v1.1.0

TypeScript version

unsure

Additional context

No response

@Oudwins Oudwins changed the title Subfield types set to unknown on optional parents Subfield types set to unknown Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant