ArkType

1.3K posts

ArkType banner
ArkType

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
Sabitlenmiş Tweet
ArkType
ArkType@arktypeio·
📢Introducing ArkRegex📢 a drop in replacement for new RegExp() with types ⬇️
English
104
398
3.2K
730.8K
ArkType
ArkType@arktypeio·
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
1
0
9
823
ArkType
ArkType@arktypeio·
📢ArkType 2.2 is here. This is a big one, and it's long overdue. Validated functions, type-safe regex, bidirectional JSON Schema, and universal schema interop. Here's what's new 🧵
ArkType tweet media
English
5
15
227
12.4K
ArkType
ArkType@arktypeio·
@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.
ArkType tweet media
English
1
0
20
723
ArkType
ArkType@arktypeio·
Standard Schema validators can now be embedded directly in ArkType definitions. Zod, Valibot, or anything else that implements the spec.
ArkType tweet media
English
2
1
50
1.3K
ArkType
ArkType@arktypeio·
@0xtiago_ #name-uuid-version-8" target="_blank" rel="nofollow noopener">rfc-editor.org/rfc/rfc9562.ht…
QME
0
0
2
143
ArkType
ArkType@arktypeio·
all you need to "learn" ArkType syntax: 1️⃣ start with a typescript keyword 2️⃣ .autocomplete to discover constraints 3️⃣ compose if needed with &, |, etc.
English
7
11
349
33.2K
ArkType
ArkType@arktypeio·
@theCTO some of it is more approachable than you might think.... but thanks🧙‍♂️
GIF
English
1
0
14
1K
adam
adam@theCTO·
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
2
0
20
1.8K
ArkType
ArkType@arktypeio·
@IsachsenCoder 💯 that is another use-case- typed functions in .js with no jsdoc required.
English
1
0
2
229
ArkType
ArkType@arktypeio·
tools are just introspectable functions... what if you could define them like this?🤔
ArkType tweet media
English
13
3
177
11.4K
ArkType
ArkType@arktypeio·
@repalash There is a fluent style available as well, but type-safe strings like this can offer more readability, concision and parallel TypeScript 1:1 for situations where they're a good fit like this. Autocomplete + type-level errors make a big difference.
English
1
0
1
75
Palash Bansal
Palash Bansal@repalash·
@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
1
0
0
67
ArkType
ArkType@arktypeio·
@repalash By default will be inferred by TS but when introspectability is needed currently it is specified with a `:` to mirror a return type annotation in TS. Considering "=>" instead which could also be a good fit (will finalize as part of 2.2 release).
ArkType tweet media
English
1
0
1
424
ArkType
ArkType@arktypeio·
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
1
0
1
68
Sahazel
Sahazel@SahazelXI·
@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
1
0
0
72
ArkType
ArkType@arktypeio·
wish TS had rust-style pattern matching? (it already does)🪄
ArkType tweet media
English
79
37
678
192.9K
ArkType
ArkType@arktypeio·
@SahazelXI if you like that aspect of it as well, this should be the perfect solution for you🎉
English
0
0
1
20
Sahazel
Sahazel@SahazelXI·
@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
1
0
1
25
ArkType
ArkType@arktypeio·
@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
0
0
1
300
ArkType
ArkType@arktypeio·
@SahazelXI i.e. you cant do: match(someVariable)({ ...cases... }) you have to do: const matcher = match({...cases...}) doThings() { macher(someVariable) }
English
3
0
7
477