Skip to content

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

Backlog

Description

@thewilkybarkid

What version of Effect is running?

4.1.2

What steps can reproduce the bug?

import { Data, Effect } from "effect"

class NotFound extends Data.TaggedError("NotFound") {}

declare const lookup: Effect.Effect<number, NotFound>

const doubled = Effect.map(lookup, (n) => n * 2)

// Compiles
export const works = Effect.catchTag(doubled, "NotFound", () => Effect.succeed(0))

// Error: No overload matches this call.
export const fails = Effect.catchTag(
  Effect.map(lookup, (n) => n * 2),
  "NotFound",
  () => Effect.succeed(0)
)

The second call reports:

No overload matches this call.
  The last overload gave the following error.
    Argument of type 'string' is not assig 'readonly [never, ...never[]]'.

Inside Effect.gen, yield* Effect.catchTag(Effect.map(...), "NotFound", ...) also reports that the result has no [Symbol.iterator](), because the en and returns a function.

What is the expected behavior?

Both calls typecheck, since they only differ in whether self is held in a variable first.

What do you see instead?

The inline version fails. It happens with TypeScript 7.0.2 and 5.9.3.

Additional information

  • Writing out the callback's parameter type ((n: number) => n * 2) doesn't help, so it isn't about inferring the callback.
  • An inline Effect.fail(new NotFound()) as self works.
  • Effect.catchTags(Effect.map(...), { NotFound: ... }) and Effect.mapError(Effect.map(...), ...) work, so it seems specific to catchTag's overloads. The data-last overload also takes up to three arguments (k, f, orElse), the same number as a data-first call, and K depends on E inferred from self.
  • Workaround: pipe(Effect.map(...), Effect.catchTag("NotFound", ...)).

Activity

  1. added
    bug
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions