Skip to content

fix: update generated code for @effect/platform compatibility#86

Open
kevinmichaelchen wants to merge 1 commit intotim-smart:mainfrom
kevinmichaelchen:fix/effect-platform-compatibility
Open

fix: update generated code for @effect/platform compatibility#86
kevinmichaelchen wants to merge 1 commit intotim-smart:mainfrom
kevinmichaelchen:fix/effect-platform-compatibility

Conversation

@kevinmichaelchen
Copy link

Summary

  • Add Scope.Scope to Effect return types in generated client interfaces
  • Add Scope import to generated client code
  • Rename bodyFormDataRecord to bodyFormData (API renamed in @effect/platform)

Problem

When using the generated clients with recent versions of @effect/platform (0.77+), TypeScript throws errors because:

  1. HttpClient.execute() now returns Effect<A, E, Scope> instead of Effect<A, E, never>
  2. HttpClientRequest.bodyFormDataRecord was renamed to bodyFormData

Example error:

Type 'Effect<A, HttpClientError | E, Scope>' is not assignable to type 'Effect<any, any, never>'.
  Type 'Scope' is not assignable to type 'never'.

Changes

Generated interface return types

Before:

readonly "getUser": (id: string) => Effect.Effect<User, HttpClientError>

After:

readonly "getUser": (id: string) => Effect.Effect<User, HttpClientError, Scope.Scope>

Generated imports

Added:

import type * as Scope from "effect/Scope"

Form data method

Changed from bodyFormDataRecord to bodyFormData.

Test plan

  • Generated clients typecheck with @effect/platform@0.77.7
  • Generated clients build successfully

- Add Scope.Scope to Effect return types in generated interfaces
- Add Scope import to generated client code
- Rename bodyFormDataRecord to bodyFormData (API changed in @effect/platform)

These changes fix TypeScript errors when using the generated clients with
recent versions of @effect/platform where HttpClient.execute returns an
Effect that requires Scope.
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