neverthrow
oxide.ts
Our great sponsors
neverthrow | oxide.ts | |
---|---|---|
16 | 4 | |
2,399 | 479 | |
- | - | |
5.3 | 0.0 | |
1 day ago | 6 months ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
neverthrow
-
Error Handling Patterns
Very timely, was just trying to understand how to improve error handling with typescript recently and came across neverthrow (https://github.com/supermacro/neverthrow) which looks promising…
-
Ask HN: What is the “proper” way to do error-handling in TypeScript?
On my team we use Rust-style Result/Option types for any unrecoverable exceptions.
-
The gotcha of unhandled promise rejections
I was happy when Promise became available, but in retrospect I'd wish we would have skipped ahead and gotten Observable (e.g: https://rxjs.dev/) instead to enable more powerful functionality and composition etc.
In Typescript dealing with rejection is also painful since rejection reasons can't be guaranteed to be Error even when you always take care of that. And it can't help you guarantee that you're handling all types of errors thrown. For that purpose I'm thinking of using https://github.com/supermacro/neverthrow#readme or https://swan-io.github.io/boxed.
-
How has learning Rust been a benefit to you in other programming areas?
I highly recommend the neverthrow library for bringing Result to Typescript.
-
How to know if a function throws in Typescript?
What do you think of neverthrow?
-
ts-results - a lightweight result wrapper to exhibit success/failure instead of using/throwing exceptions.
I use https://github.com/supermacro/neverthrow for this
- Why doesn't typescript have a throws type to annotate functions that can throw an error?
-
what's the recommended way to handle error in TS?
I use Neverthrow. Same idea, concurrent projects...
-
I created a package that adds Rust-like features to TypeScript
You might also be interested in neverthrow https://github.com/supermacro/neverthrow
-
Simple and maintainable error-handling in TypeScript
It's very easy to build your own versions of the above error handling yourself, and in fact, I'd recommend it as a learning exercise if you want to become more familiar with TypeScript. But of course, there are many packages out there to help you. Some examples — in no particular order — include, purify-ts, fp-ts, and neverthrow. You’ll notice that a couple of those examples are functional programming libraries, this is because errors can be well-modelled with monads.
oxide.ts
-
oxide.ts - my Rust-inspired Option/Result and match library for TypeScript - Version 1.0 Release
You can check out the npm page or the GitHub repository
-
oxide.ts - Big update to my Rust-inspired Option/Result library
Resources: change log - npm page -github branch
- I created a package that adds Rust-like features to TypeScript
What are some alternatives?
ts-results - A typescript implementation of Rust's Result object.
fp-ts - Functional programming in TypeScript
result - A TypeScript result type taking cues from Rust's Result and Haskell's Either types
functional-conditionals - A library for writing if / else if / else in a functional way.
eslint-plugin-promise - Enforce best practices for JavaScript promises
TypeScript - TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
dbg-expr - A helper for evalutating and logging an expression at the same time.
ts-results - Lightweight Javascript library developed to solve a common problem. It returns an object indicating success or failure of an operation instead of throwing/using exceptions
protonic-ui - React native UI Kit for mobile apps.