question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Result.ok() gone in 5.x

See original GitHub issue

We’re upgrading from 4.1.1 to 5.1.0 and one large change we needed to do in our codebase was to replace Result.ok() with Result.ok(Unit) or else we were getting:

Error: Tried to construct `Ok` with `null`. Maybe you want `Maybe.Nothing`?

Two things I’d like to ask:

  1. Why is this a runtime check instead of a compile time check? The .d.ts files contain export declare function ok<T, E>(): Result<Unit, E>; so all our code typechecked, but it blows up in runtime. If this is not a function call users of the library should not make then I think ideally it shouldn’t typecheck.
  2. Can we get this convenience method back? One of the nice things about true-myth is that Result, Maybe, and Unit types are nicely connected to each other and this was one of the nicenesses. On using Maybe instead of Result: I think Maybe<ErrorType> is not as clear as Result<Unit, ErrorType> in terms of what the code is doing.

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
krivachycommented, Dec 16, 2021

Thanks for the speedy fix @chriskrycho! We love to use true-myth 🔮 in our codebase ❤️

0reactions
chriskrychocommented, Dec 16, 2021

Fix released in v5.1.1. Thanks again for the report!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Converting Result to Option with .ok() : r/rust - Reddit
I came across this when trying to convert a result into an option. Naturally, I tried .into() assuming that would work (spoiler alert, ......
Read more >
How to use Result in Swift
Working with Result​​ First, Result has a get() method that either returns the successful value if it exists, or throws its error otherwise....
Read more >
How to use Result correctly? - rust - Stack Overflow
Result is an enum which can be one of two variants: either Ok(. ... Instead what you can do is map the error...
Read more >
Recoverable Errors with Result - The Rust Programming ...
When the result is Ok , this code will return the inner file value out of the Ok ... returned by error.kind() is...
Read more >
Algebra Calculator - Microsoft Math Solver
In mathematics, a square root of a number x is a number y such that y² = x; in other words, a number...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found