Skip to content

Fix effectGenToFn return type conversion#635

Merged
mattiamanzati merged 1 commit intomainfrom
fix/effectGenToFn-return-type
Feb 3, 2026
Merged

Fix effectGenToFn return type conversion#635
mattiamanzati merged 1 commit intomainfrom
fix/effectGenToFn-return-type

Conversation

@mattiamanzati
Copy link
Contributor

Summary

  • Fixes the effectGenToFn refactor to correctly convert Effect<A, E, R> return type annotations to Effect.fn.Return<A, E, R> when transforming Effect.gen to Effect.fn
  • Previously the refactor kept the original Effect.Effect<...> return type, producing code that doesn't compile
  • Resolves the imported Effect module identifier to use in the generated Effect.fn.Return type reference

Example

Before this fix, the refactor would produce:

// Broken output (doesn't compile)
const someFunction = Effect.fn("someFunction")(function* (value: string): Effect.Effect<number, boolean> {
  // ...
})

After this fix:

// Correct output
const someFunction = Effect.fn("someFunction")(function* (value: string): Effect.fn.Return<number, boolean, never> {
  // ...
})

Test plan

  • Added test example effectGenToFn_returns.ts with two cases (concise body and generics)
  • Verified snapshot outputs show correct Effect.fn.Return<A, E, R> type
  • All 491 existing tests pass
  • TypeScript type checking passes

Closes #634

🤖 Generated with Claude Code

When converting Effect.gen to Effect.fn, the return type annotation is now
correctly transformed from Effect<A, E, R> to Effect.fn.Return<A, E, R>,
preventing the refactor from producing code that doesn't compile.

Closes #634

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Feb 3, 2026

🦋 Changeset detected

Latest commit: 450b28c

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

This PR includes changesets to release 1 package
Name Type
@effect/language-service 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

@mattiamanzati mattiamanzati merged commit b16fd37 into main Feb 3, 2026
6 checks passed
@mattiamanzati mattiamanzati deleted the fix/effectGenToFn-return-type branch February 3, 2026 14:07
@github-actions github-actions bot mentioned this pull request Feb 3, 2026
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.

Convert to fn doesn't handle return types correctly

1 participant