Sabitlenmiş Tweet
ArkType
1.3K posts

ArkType
@arktypeio
TypeScript's 1:1 validator, optimized from editor to runtime ⛵ ⭐https://t.co/xbZ88YqNcO 👋https://t.co/ve4WN4MhQK
Katılım Eylül 2022
3 Takip Edilen6K Takipçiler

Full announcement: arktype.io/docs/blog/2.2
I couldn't be more hyped to see what you do with it.
⚡ arktype.io/docs/intro/set…
⭐ github.com/arktypeio/arkt…
👋 arktype.io/discord
If you want to support this work: github.com/sponsors/arkty…
English

Much more:
- select + configure — query types by node kind, configure specific references
- Improved type.declare — morph-aware declarations, optionality via property values
- type.or, type.and, type.merge, type.pipe — n-ary standalone operators
- "|>" string-embeddable pipe syntax
- type.valueOf for TS enums
- string.hex + string.regex keywords
- Serializable ArkErrors (flatByPath, flatProblemsByPath, toJSON)
- exactOptionalPropertyTypes config
- ES2020 + Hermes compatibility
- In-docs playground
English

@ark/json-schema — Bidirectional JSON Schema
Parse JSON Schema into ArkType Types, and convert Types to JSON Schema. Huge thanks to @TizzySaurus for building this one.
toJsonSchema() now supports configurable fallbacks, draft-07/2020-12 targets, and cyclic types. 11 granular fallback codes for handling incompatibilities your way.

English

📚 docs: arktype.io
👋 discord: arktype.io/discord
⭐ github: github.com/arktypeio/arkt…
🛝 playground: arktype.io/playground
English

there's one library i know for a fact i can never contribute to because the code will literally take me 3-5 business years to understand.
hey @arktypeio y'all are magic ❤️
English

@IsachsenCoder 💯 that is another use-case- typed functions in .js with no jsdoc required.
English

@repalash That was actually @colinhacks' idea- definitely considering it😁
English

@arktypeio Why use strings instead of builder style like in zod etc? Strings don't work well with autocomplete, unless you'll write a parser for regular ts.
Also in this case won't it be consistent to have fn(...params)(ret)(func)
English

for object definitions, you can either use a Scope if you want to string embed everything by referring to custom aliases:
arktype.io/docs/scopes
use `.at` to narrow on specific properties:
#narrowing-input-with-in-property-matching-with-at" target="_blank" rel="nofollow noopener">arktype.io/docs/match#nar…
or use .case chaining to pass object definitions directly:
#fluent-api" target="_blank" rel="nofollow noopener">arktype.io/docs/match#flu…
there is no ability yet in arktype to define comparison behavior for custom types although it sounds like from what you're describing you wouldn't need it because these would still be numbers.
English

@arktypeio i do have a question tho, would something like be possible?
const matcher = match({
"1 < this.x < 10" => ...
"1 < this.y < 10" => ...
})
matcher(new Point(10,10))
or a way to "overload" the comparison function?
English

@SahazelXI if you like that aspect of it as well, this should be the perfect solution for you🎉
English

@arktypeio that's even better because it allows you build a generic matcher that can be reused elsewhere or even be replaced pretty neatly, pretty good design decision
English

@SahazelXI which sometimes is great since the matcher is reusable but in other cases, inheriting the input type directly from the variable you want to use is very convenient (this is how ts-pattern works).
English

@SahazelXI i.e. you cant do:
match(someVariable)({ ...cases... })
you have to do:
const matcher = match({...cases...})
doThings() {
macher(someVariable)
}
English






