Skip to content

fix: infer union errors in Err.asyncAndThrough - #687

Open
lfhwnqe wants to merge 2 commits into
supermacro:masterfrom
lfhwnqe:fix/async-and-through-error-inference
Open

lfhwnqe wants to merge 2 commits into
supermacro:masterfrom
lfhwnqe:fix/async-and-through-error-inference

Conversation

@lfhwnqe

@lfhwnqe lfhwnqe commented Nov 5, 2026

Copy link
Copy Markdown

Passing a callback that returns ResultAsync<unknown, string> | ResultAsync<unknown, number> to Err.asyncAndThrough, or to a Result union, currently fails type checking. Ok.asyncAndThrough already supports this inference, but the Err overload does not.

Mirror the existing inferred overload on Err. Add exact type assertions through both Err and Result public types. Runtime short-circuit behavior is unchanged.

Validation: the two calls fail with TS2345 before the fix. Afterward, npm test passes 117 runtime tests and all type tests, including the new assertions; npm run typecheck, npm run lint, and npm run build pass.

AI assistance: this change and its regression tests were developed with OpenAI Codex. The listed checks were run locally.

@changeset-bot

changeset-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6ce0c8b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
neverthrow Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant