Record fields with numbers as keys does not work as excpected
Describe the bug
I've added Record field, so, type looks like this
interface FormType {
items: Record<number, {quantity: number}>
}
Types in form work well, Field with name items.${number}.quantity works. So, items in state are {} and when I change quantity for item with 64, it replaces items value with [null, null, null, ..., 64]
I also discovered, that if record keys are strings(contains any non-numeric character), it works fine.
Your minimal, reproducible example
https://codesandbox.io/p/devbox/zen-black-47s6fg?workspaceId=ca4463b1-f681-4a01-8bea-2aa832081a3a
Steps to reproduce
To reproduce a bug with number keys
- Run example
- Change something in inputs
- Press submit
- Check console
To verify that it works with string keys
- Uncomment next lines:
items: Record<string, { quantity?: number }>;,<form.Field key={item} name={\items.item-${item}.quantity`}>` - Comment next lines after uncommented
- Change something in inputs
- Press submit
- Check console
Expected behavior
Even if I use numeric keys, it should work as record, not create array. Probably it could be recognised from array fields by existing of []
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
TanStack Form adapter
react-form
TanStack Form version
v34.0
TypeScript version
No response
Additional context
No response