Skip to content

fix(effect): preserve tagged errors for an inline self in data-first Effect.catchTag - #10901

Open
EnesKartal wants to merge 4 commits into
Effect-TS:mainfrom
EnesKartal:fix/effect-catch-tag-inline-map
Open

EnesKartal wants to merge 4 commits into
Effect-TS:mainfrom
EnesKartal:fix/effect-catch-tag-inline-map

Conversation

@EnesKartal

@EnesKartal EnesKartal commented Nov 24, 2026 •

Copy link
Copy Markdown

Closes #10889
Closes EFF-4276

Summary

Data-first Effect.catchTag(Effect.map(lookup, (n) => n * 2), "NotFound", handler) failed overload resolution, although hoisting the Effect.map(...) call into a variable typechecked.

Effect.map is a dual API, so TypeScript defers the inline call during its first inference pass. E then had no candidates and fell back to unknown, Tags<unknown> is never, and the tag was rejected before the second pass could infer E.

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 after E; those use unknown (or never for K), which matches what inference already fell back to. The type parameter order is unchanged, so calls with explicit type arguments such as HttpClient.catchTag still compile. A genuinely unknown error channel is still rejected.

Type tests in packages/effect/typetest/Effect.tst.ts cover inline Effect.map(...) with a single tag, a tag array and orElse, plus rejection of unknown tags and of an unknown error channel.

Verification

  • pnpm test-types Effect.tst.ts passes on TypeScript 5.9.3 and 6.0.3 (324 tests, 488 assertions, 36 suppressed errors matched)
  • pnpm check
  • pnpm lint
  • pnpm jsdocs --check

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 993e5c8

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

This PR includes changesets to release 40 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator 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

@effect-janitor effect-janitor Bot added the 4.0 label Nov 24, 2026
…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.
@effect-bot effect-bot changed the title fix(effect): infer catchTag key before matching inline Effect error type fix(effect): preserve tagged errors for an inline self in data-first Effect.catchTag Nov 25, 2026

This branch is waiting to be deployed

1 waiting deployment
fork — 993e5c86 Waiting Nov 25, 2026 by effect-bot via approval-gate #27311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data-first Effect.catchTag doesn't typecheck when self is an inline Effect.map call

2 participants