Profile avatar
arktype.io
TypeScript's 1:1 validator, optimized from editor to runtime ⛵ ⭐http://github.com/arktypeio/arktype 👋http://arktype.io/discord
180 posts 403 followers 3 following
Regular Contributor
Active Commenter
comment in response to post
Cleaner types await: arktype.io
comment in response to post
⭐ github.com/arktypeio/ar... 🙏
comment in response to post
From CONTRIBUTING.md: github.com/arktypeio/ar...
comment in response to post
Regex parsing will include descriptive type errors and precise inference up to a certain size. We're using a new strategy to ensure it can fall back gracefully rather than crashing TS. Small bonus preview:
comment in response to post
So technically... you're right, there is the one function. There's just no DSL or anything.
comment in response to post
The parser is primarily developed for ArkType to be able to infer regex patterns from pure string syntax. I think David was working on a string API like this for Magic RegExp, but I don't know if that landed. We'd like to support match extraction eventually, but for now it's focused on `.test`.
comment in response to post
Once chained expressions and strings literals can trigger them, the new language server will have everything we need to migrate🏎️ github.com/microsoft/ty...
comment in response to post
To be fair you can use a regex literal like /.*/ and get that!
comment in response to post
Love @danielroe.dev and this is a great library! The ArkType util will work quite differently as there is no runtime logic or transform step. It's more like a precise lint rule that will tell if you make a mistake and can infer out a Regex that narrows strings it `.test`s.
comment in response to post
(technically there would be a couple bytes for the wrapper function)
comment in response to post
It should be possible but would need more details. Feel free to ask in the Discord! arktype.io/discord
comment in response to post
Here are a few ideas: ✅APIs that would otherwise be impossible or unsafe ✅globally toggle checking on/off depending on env ✅type-safe function inputs in .js without jsdoc
comment in response to post
ArkType has a `.expression` prop that is close to TS syntax, but it includes additional syntax for constraints like ranges and divisors. Should work if your types don't include those things though.
comment in response to post
You'll have to wait for the release announcement! (if you're really motivated to go digging you can check recent PRs)
comment in response to post
To dispel any possible ambiguity, "shitescript" refers to code where casting is used as a first resort to obfuscate real errors from typescript, which is objectively a god-tier language🐐
comment in response to post
To say fn is the tip of the iceberg would be an overstatement. There's also... - type-safe regex - toJsonSchema config: handle any input Type - @ark/json-schema: parse JSON Schema => ArkType - declare: define a schema for an existing type - select: deep query + transform ...
comment in response to post
Agree, but these aren't magic! Try breaking the syntax and see what kinds of type errors you get. They're often better than what you'd get natively from your editor. arktype.io/playground
comment in response to post
ArkType can actually be used to add types to vanilla JS without JSDoc! Keep an eye out for the upcoming 2.2 announcement 👀
comment in response to post
There are builder pattern APIs as well that can help you adapt and are also ideal for some patterns! You can see them by clicking the "fluent" tab in examples throughout the docs.
comment in response to post
Benefits of defining schemas with TypeScript syntax: ✅inherit your knowledge of TS ✅see how your schema is inferred at a glance ✅definitions 50% shorter on average ✅equally safe + responsive See for yourself. arktype.io/playground
comment in response to post
Other helpful links: Scopes: arktype.io/docs/scopes Intro: arktype.io Discord: arktype.io/discord GitHub: github.com/arktypeio/ar...
comment in response to post
Try it with our new playground🛝 arktype.io/playground?c...
comment in response to post
ArkType also has fluent apis like `.merge` and `.or` as well which can definitely help! We're to write up a full migration guide this week ✏️
comment in response to post
We shipped some big improvements to the playground over the weekend. Really hoping it feels local-quality now. If not, let us know! arktype.io/playground
comment in response to post
We hope you enjoyed this Monday's episode of "why build another TypeScript validator?" Docs: arktype.io GitHub: github.com/arktypeio/ar... Discord: arktype.io/discord
comment in response to post
This has *massive* potential, especially when combined with other libraries that can benefit from a deeper understanding of your data like ORMs. Also, if you're anything like us, it's a ton of fun to mess around with🛝 arktype.io/playground?c...
comment in response to post
So what's the point of all this? ✅every type is automatically optimized ✅unsatisfiable types fail when initialized ✅allows rich runtime introspection There are lots of great schema libraries, but none of them can do these things the way ArkType can.
comment in response to post
If you think this feature was tacked on, guess again. ArkType is built from the ground up to understand your types and their relationships- often more precisely than TypeScript itself🎯
comment in response to post
5% of creating "typescript for runtime" was mirroring the same syntax. 95% was mirroring the set-theoretic introspectability.