Compiler Result implementations reject valid variant-changing chains
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript, typescript
- Domain
- tooling
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.
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.
- Dominant language
- JavaScript
- Stars
- 251k
- Forks
- 51.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 51
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.
More from react/react
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·
-
client-controller-update ta-bot-triage team-money-movement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MetaMask/metamask-mobile#36594 ·