Defining and inferring a generic type defined inside a scope
I'm brand new to this library so I'm sorry if I'm doing something dumb, but I'm not sure how I can define a generic inside a scope. My broken code looks like this:
And I have the following errors:
Property 'infer' does not exist on type 'Generic<[["t", unknown]], { readonly kind: "foo"; readonly payload: "t"; }, {}, { foo: { bar: "biz"; }; request: bindGenericToScope<GenericAst<[["t", unknown]], { readonly kind: "foo"; readonly payload: "t"; }, {}, {}>, bootstrapAliases<...>>; }>'.ts(2339)
8 Replies
Don't want anyone to waste their time helping me so I thought I'd say I ended up going with Zod. Looking forward to trying this out again once it's more mature, there's better documentation, and more examples. 🫡
@mailliW Sorry I missed this! Been a bit overwhelmed trying to keep up with everything lately.
Sorry the docs are very limited. There is this example of defining a generic directly in a scope:
https://arktype.io/reference/generics/#scoped
My general advice would be if you're just getting into the library, you probably don't need generics. You could just use an intersection (
.and
or &
) to add a set of base properties.
I am working on the new docs now though, so do stay tuned for that! I hope it will make things a lot clearerThank you sir! Don't be sorry.. I'm not obligated to your time. I understand you are busy so thanks for making time to respond. I appreciate it
I'm not too far along, maybe I'll give it another go this weekend. You have a Venmo or Cashapp or something? I'm only considering using Arktype in side projects for now (I don't have enough sway at my job for such decisions) so I don't have a huge budget, but if you look out for my questions in the future I can send you a little bit for your time.
That's very nice of you! If you want you can sponsor the project on GitHub https://github.com/sponsors/arktypeio
GitHub
Sponsor @arktypeio on GitHub Sponsors
ArkType is a type-safe runtime validator that understands TypeScript syntax.
Each character you type is statically parsed so you'll know exactly what to expect from editor to runtime.
Cool, will do! 🙂
@mailliW I was trying to figure out if you were the one who recently sponsored the GitHub, then I realized your @ was also your name spelled backwards 😅 Thanks again for your support, it is really helpful 💖
Let me know if you have an X/Bsky account you'd like me to shout out
No problem at all! I appreciate the offer, but I've been "off the grid" for a few years. I've been considering starting that back up because I'm about to make an attempt a startup, but I haven't yet! 🙂
Thanks for your effort and time on Arktype and on here! 🤗
Very cool, good luck and don't hesitate to reach out if you have more questions 😊