News for hackers. Stuff that matters.
Re:TypeScript 5.0 by treis on Thursday March 16, 2023 @06:02PM (#35189409)
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.

Re:TypeScript 5.0 by epolanski on Thursday March 16, 2023 @06:28PM (#35189742)
You can do all you list with effect-ts/schema.

Arguably the highest quality TS lib out there.

https://github.com/Effect-TS/schema

Re:TypeScript 5.0 by munbun on Friday March 17, 2023 @12:34AM (#35193156)
this looks like a better documented io-ts
Re:TypeScript 5.0 by epolanski on Friday March 17, 2023 @05:45AM (#35195001)
The 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.

Re:TypeScript 5.0 by iainmerrick on Friday March 17, 2023 @05:52AM (#35195040)
At 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.

Re:TypeScript 5.0 by chatmasta on Friday March 17, 2023 @07:03PM (#35204055)
In 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.
Re:TypeScript 5.0 by treis on Friday March 17, 2023 @09:30AM (#35196815)
The 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.