Compiler Result implementations reject valid variant-changing chains
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 251k
- Forks
- 51.4k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 53
Description
React version
Current main (2dc7da790d63).
Steps to reproduce
Type-check direct compiler utility chains such as:
Ok(2).andThen(() => Err("failed"));
Ok(2).and(Err("failed"));
Err("failed").or(Ok(4));
Err("failed").orElse(() => Ok(4));
Current behavior
The concrete OkImpl combinators fix the error type to never; ErrImpl.or fixes the success type to never; and ErrImpl.orElse accepts only another ErrImpl. These valid variant-changing chains fail TypeScript compilation with TS2322/TS2345 even though their runtime implementations naturally return the supplied result.
Expected behavior
The concrete implementations should preserve the Rust-style Result combinator behavior and infer the success/error types of the returned result without changing runtime semantics.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the OkImpl and ErrImpl Result implementations and type-check the four variant-changing examples in the issue. Update the concrete combinator typings so those examples compile while preserving runtime behavior, then verify the TypeScript errors are gone and existing checks still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100