Repository navigation
fix(effect): preserve tagged errors for an inline self in data-first Effect.catchTag - #10901
Open
EnesKartal wants to merge 4 commits into
Open
EnesKartal wants to merge 4 commits into
EnesKartal wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 993e5c8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
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 |
…fect.catchTag Co-authored-by: EnesKartal <[email protected]>
effect-bot
force-pushed
the
fix/effect-catch-tag-inline-map
branch
from
November 25, 2026 00:11
3ff603d to
3a3a723
Compare
…arameter default Replace the extra `Self`-based data-first overload with an `E = any` default on the existing one. While TypeScript defers an inline `self` such as `Effect.map(...)`, `E` now falls back to `any` instead of `unknown`, so the tag survives to the second inference pass. A genuinely `unknown` error channel is still rejected. This also drops the duplicated overload from internal/effect.ts.
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10889
Closes EFF-4276
Summary
Data-first
Effect.catchTag(Effect.map(lookup, (n) => n * 2), "NotFound", handler)failed overload resolution, although hoisting theEffect.map(...)call into a variable typechecked.Effect.mapis a dual API, so TypeScript defers the inline call during its first inference pass.Ethen had no candidates and fell back tounknown,Tags<unknown>isnever, and the tag was rejected before the second pass could inferE.The data-first overload now declares
E = any, so the tag survives the first pass and is checked against the real error type in the second. TypeScript requires a default on every type parameter afterE; those useunknown(orneverforK), which matches what inference already fell back to. The type parameter order is unchanged, so calls with explicit type arguments such asHttpClient.catchTagstill compile. A genuinelyunknownerror channel is still rejected.Type tests in
packages/effect/typetest/Effect.tst.tscover inlineEffect.map(...)with a single tag, a tag array andorElse, plus rejection of unknown tags and of anunknownerror channel.Verification
pnpm test-types Effect.tst.tspasses on TypeScript 5.9.3 and 6.0.3 (324 tests, 488 assertions, 36 suppressed errors matched)pnpm checkpnpm lintpnpm jsdocs --check