#02: Strictly<T>, Effect-TS, Result<T>, Prisma 5.0
Discover Strict Object Types, Prisma is finally getting the long awaited speed boost and Bid Farewell to Exceptions with Results and Effects!
Welcome to the second edition of the ByteBullet newsletter! Get ready to dive into a range of fascinating topics that await you in this week's issue.
Here's a sneak peek of what's in store:
Strictly<T> - strict object type you’ve always wanted
Prisma 5.0 - the long awaited speed bump
Effect-TS - functional effect system for TS
@badrap/result - result type taking cues from Rust and Haskell
But before we jump into these topics, I'd like to personally invite you to connect with me on Twitter at @ByteBulletDev. It's the place where I share intriguing updates and engage in discussions about TypeScript and React. Feel free to hit me up!
Make it Strict
You would expect the following code to compile with an error, because the returnWhatIWant
function expects to return at least Doggo.
The code works without any problems. Imagine we are not returning a dog but crucial user details, then this could result in data leaks. This is where the Strictly<T> comes in handy.
I have to leave a note here. If you have any sensitive data or data that you are not 100% sure about, use a validator like Typia, zod or yup. If you have not heard about Typia then checkout my previous edition!
Prisma 5.0 speed bump
This week version 5.0 was released for the prisma project. It brings many features and improvements with the main highlight being the long awaited speed boost. They have achieved it thanks to replacing the GraphQL like protocol between the prisma client and query engine with jsonProtocol.
Sadly I cannot fit in all of the changes, so here is the whole changelog.
Effect-TS (Haskell again?)
Functional paradigm is a powerful toy when used correctly. This is where tools like Effect-TS or TS-Pattern from my previous edition come in. Effect brings you, the programmer, ability to effortlessly handle async operations, manage errors, and compose complex workflows in a concise and type-safe manner. With improved testability and enhanced code maintainability, Effect-TS unlocks new levels of productivity for TypeScript developers.
Result<T>
And to finish this weeks round up we take a look at the @badrap/result. This Type removes all the hassle from exception handling. As always, code is more descriptive than words:
The Result type is smart and knows what you are accessing. You can see that if you access isErr, then the error variable is available. The same goes for the isOk value.
See you next Saturday!
If you want to reach me, hit me up on twitter @ByteBulletDev