-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add ResultValue
and ResultError
helper types
#591
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Luca Schultz <[email protected]>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a fine addition though I haven't found a need for it myself.
Would you consider naming them OkType and ErrType? It seems clearer to me. Not married to either.
Splitting each into its own file could be a bit scattered, it might be easier to put them both in a common types.ts
.
I actually realized the codebase already had utility types like these. So I moved them into the respective
Maybe @supermacro or @m-shaka can help? 😌 |
For the circular dependency problem - you can likely sidestep it using The other import problem seems to be an issue with using absolute imports: I did also notice that tsconfig.tests.json sets |
Hi,
I've been enjoying neverthrow for a while now. Since I try to rely on type inference as much as possible, I used some version of the types added in this PR in each project I used neverthrow in. Basically, they allow using this pattern:
Even better would be a version that would allow something like:
But I couldn't figure out a straightforward way to achieve this (maybe @mattpocock could help). I would love to see these added, as not every TS developer knows how to use TS features like conditional types and infer, and having them be part of the library could encourage more developers to rely on type inference.