Why can't I infer Type
like more basic generic objects, without hoisting generics?
#1315
Unanswered
inducingchaos
asked this question in
Q&A
Replies: 1 comment
-
Just looking back on this, to make it a bit clearer: ArkType's For example with my original workaround, in my
But when I uncomment the aliases, I get:
Any ideas? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I apologize if this is unclear, I don't really know how to specify this lol. Most of the code is just contextual complexity, demonstrating the difference I'm highlighting - but I simplified it to only depend on TypeScript and ArkType.
I want to use
Type
,Type["infer"]
, andtype
in a very similar way that I useDynamicType
andcreateDynamicType
below.In my mind, this should just work... maybe ArkType's internals (I saw some
NoInfer
's somewhere) prevent this. I achieved genericness like this before by generic-drilling all the way down from the create function, but unfortunately with records, this is an impossible feat if you want separate types for separate keys.The solution (for my basic implementation) was to NOT use generics, and use a validator type in the function only - read more about this here.
Am I missing something here, maybe an alias type or pattern specific to ArkType?
P.S. I switched from Zod for the serializable aspect and I ❤️ it so far. You guys are killing it.
Beta Was this translation helpful? Give feedback.
All reactions