5 ms·
The jankiness of JS combined with the correctness of TS really is a powerful combo. Especially stuff like string keys and const arrays as enums make safe and r
by treis 4y ago
The jankiness of JS combined with the correctness of TS really is a powerful combo. Especially stuff like string keys and const arrays as enums make safe and readable code without a lot ceremony.
The big problem is the gap between TS and JS. User defined typeguards are a usable work around but it would be nice to be able to use a native isMyType function.
Also would be nice to have constraints natively in types. Like string lengths or max ints.
- epolanski 4y agoYou can do all you list with effect-ts/schema. Arguably the highest quality TS lib out there. https://github.com/Effect-TS/schema https://github.com/Effect-TS/schema
- munbun 4y agothis looks like a better documented io-ts
- epolanski 4y agoThe author is the same of io-ts and t-comb, but capabilities go well beyond io-ts (including the experimental modules). Being able to generate types, encoders, decoders, apis, guards and even arbitrary data is extremely powerful.
- iainmerrick 4y agoAt first glance this looks similar to Zod (which is listed as an influence). What does @effect/schema do differently/better? I feel like the name could use a bit of work for a start! "schema" is way too generic.
- chatmasta 4y agoIn our project at work, we've been using superstruct since 2021, but if we started today we'd probably choose Zod. We also use fp-ts, and it looks like effect-ts is a recent project by the same author, which certainly gets my attention.
- treis 4y agoThe sibling post illustrate the problem. Lots of different libraries in this area and hard to know which one to pick. Also just kind of seems wrong to use a library for types in a language that is for types only.