T
TanStackโ€ข3w ago
afraid-scarlet

Type inference issue with MomentJS

Hello! I discovered this library recently andI have been trying to see if it could fit our needs in our project. As I was testing for a date field with MUI and MomentJS, I started facing a "Type instantiation is excessively deep and possibly infinite" error from TypeScript. Based on the FAQ, it seems it could by an issue on your side, so I made a small reproduction: https://codesandbox.io/p/devbox/confident-smoke-hyn4nl It's also possible I'm doing something wrong, but then I don't know what ๐Ÿ˜… Thanks a lot for your help!
10 Replies
deep-jade
deep-jadeโ€ข3w ago
looks like the reproduction is having a hard time installing correctly. Could you give a small step-by-step description so I can test it myself?
afraid-scarlet
afraid-scarletOPโ€ข3w ago
Yes, I had issues having moment correctly included in the repro, not sure why... So what I did was simply add an MUI date field to the form composition example and cleaned up to a minimal state.
deep-jade
deep-jadeโ€ข3w ago
wait, yeah I can just copy the files and install whatever's imported my initial hunch is that it's a recursive type that's causing it, but I'll confirm it first
afraid-scarlet
afraid-scarletOPโ€ข3w ago
Awesome thanks. Just check the versions for the packages, I made the repro based on these pinned versions because that's the ones we have in our project
deep-jade
deep-jadeโ€ข3w ago
yup, as I thought. Here's the reproducible example:
const test: DeepKeys<moment.Moment> = ""
const test: DeepKeys<moment.Moment> = ""
didn't see recursive typing at first, but we currently don't have a stop condition for it which means typescript tries to infer an infinite possibilities of form names
deep-jade
deep-jadeโ€ข3w ago
GitHub
Recursive type, breaks the typesafety ยท Issue #1553 ยท TanStack/form
Describe the bug If I have an object, that can reference itself. It will break the type-safety of the form. For example here the list is any, and the function getFieldValue or the property name on ...
afraid-scarlet
afraid-scarletOPโ€ข3w ago
Ok, I see. Thank you! Is there any known workaround for it?
deep-jade
deep-jadeโ€ข3w ago
not that I know of, but reports were sparse so far. Momentjs is a pretty common library though, so feel free to leave a comment on the linked issue about it. I'll also bring it up to the group ๐Ÿ‘
afraid-scarlet
afraid-scarletOPโ€ข3w ago
Alright, will do! I will try to create a new repro that is not broken, if I can. Else I will put that one, better than nothing I guess
deep-jade
deep-jadeโ€ข3w ago
DeepKeys is importable, so that one LOC I sent is already a reproducible example

Did you find this page helpful?