Form Composition - withForm - TypeScript error
Hello!
I apologise in advance for the length of this message. I am in the process of updating my applications to TanStack Form v1 and testing to fully understand the new features/APIs.
Having seen that it is now possible to split up large forms using
withForm
(which is great), I decided to do a relatively simple test. Unfortunately, I am encountering a TypeScript error. So I would like to see if anyone knows if this is due to a problem of understanding on my part, or a potential bug that could be fixed.29 Replies
deep-jadeOP•7mo ago
form-context.tsx
:
UserInfoForm.tsx
:
AdressForm
:
UserEditFormScreen.tsx
The error I encounter :
The only way I've found so far to avoid the TypeScript error is to add an as any
to form.
ratty-blush•7mo ago
What version of TS are you using?
deep-jadeOP•7mo ago
Currently version 5.8.2. This is my configuration:
ratty-blush•7mo ago
Strange. Can you make a minimal repro error and a bug issue on GH and I'll investigate?
deep-jadeOP•7mo ago
Obviously, I'm preparing this very quickly. Thanks for your help !
ratty-blush•7mo ago
Ofc! Sorry you ran into this 😅
deep-jadeOP•7mo ago
There's no need to apologise; it's understandable that not everything is perfect. The main thing is that we all work together in advance 😉.
Here is the repository: https://github.com/philippe-desplats/tanstack-form-withform
I have tried to do something that comes as close as possible to the environment of our project.
GitHub
GitHub - philippe-desplats/tanstack-form-withform
Contribute to philippe-desplats/tanstack-form-withform development by creating an account on GitHub.
deep-jadeOP•7mo ago
I'll let you look, I'm going rest. See you soon and thank you for your help!
ratty-blush•7mo ago
You're awesome, thanks a bunch!
afraid-scarlet•7mo ago
is a repro/issue up yet? if not, I can help creating one. Fairly certain I‘ve run into this same problem before
ratty-blush•7mo ago
There'a repro from here:
https://github.com/philippe-desplats/tanstack-form-withform
But no GH issue yet - setting one up would be helpful! Thank you
GitHub
GitHub - philippe-desplats/tanstack-form-withform
Contribute to philippe-desplats/tanstack-form-withform development by creating an account on GitHub.
deep-jadeOP•7mo ago
Hey! Sorry, I forgot to publish the issue on Tanstack Form's GitHub, my apologies! @Luca | LeCarbonator did you do it? Otherwise I'll take care of it!
afraid-scarlet•7mo ago
not yet! I was busy with some other stuff
deep-jadeOP•7mo ago
It is in progress 😉 !
afraid-scarlet•7mo ago
glad to hear! let me know when you uploaded it
deep-jadeOP•7mo ago
GitHub
Issues · TanStack/form
🤖 Headless, performant, and type-safe form state management for TS/JS, React, Vue, Angular, Solid, and Lit. - Issues · TanStack/form
afraid-scarlet•7mo ago
well that was quick :Bueno:
yappiest-sapphire•6mo ago
@Redek I had a simillar issue with
... is not assignable to type 'IntrinsicAttributes'.
, after updating typescript
it went awayafraid-scarlet•6mo ago
strange. Did you perhaps forget to add the
props
argument to the render
function?deep-jadeOP•6mo ago
Thank you for your feedback. Although I am using the latest version of TypeScript and TanStack Form, I still have the same problem. I have tried dozens of different codes, without solving the problem.
It doesn't matter, I will test TanStack Form later. Thank you all for your help!
genetic-orange•5mo ago
Any updates on this? I think I’m running into the same issue as well on latest version. Trying to have two “subforms” created by the
withForm
hook and then using them in a useAppForm
typescript is giving me errors because each withForm
options is only a subset of the parent useAppForm
options. Is this not possible?genetic-orange•5mo ago
GitHub
withForm types break if defaultValues includes any extra field · I...
Describe the bug Using withForm breaks whenever any extra field is added to the parents defaultValues. import './App.css' import { useAppForm, withForm } from './hooks/form' functio...
genetic-orange•5mo ago
Similar more current issue, would be nice to see the team revisit this one.
rival-black•5mo ago
piggybacking on this, we should have a HOF wrapper like
withForm
but for non-components (like hooks and regular functions) since manually typing things from tsform is discouragedratty-blush•5mo ago
Interesting! What do you have in mind as an API? And where would it be used?
afraid-scarlet•5mo ago
someone brought up a wrapper that accepts a zod schema, generates defaultValues based on it, and then creates a useform with defaultValues and validators filled out. I forgot which post it was though
ratty-blush•5mo ago
This... Is actually an interesting idea 🕵️
But IDK how it'd fill out
defaultValues
for youafraid-scarlet•5mo ago
found the post: https://github.com/TanStack/form/discussions/1434
GitHub
How to extend the useForm hook? · TanStack form · Discussion #1434
Hello, I'm new to the @tanstack/react-form library and I need help with customizing the useForm hook. What exactly do I want? Let's say I have a Zod schema for each of my forms: const Perso...
afraid-scarlet•5mo ago
custom implementation, just some function they called