Effect CommunityEC
Effect Community2w ago
3 replies
Semaelse

Ergonomic Overloads for Service Methods in TypeScript

Is there an ergonomic way too work with overloads on service methods?

createWorkspaceIntegrations: {
      (params: {
        workspaceId: WorkspaceId;
        createdByMemberId: MemberId;
        workspaceIntegrations: WorkspaceIntegrationToCreate;
      }): Effect.Effect<WorkspaceIntegration, InternalIntegrationModuleError>;
      (params: {
        workspaceId: WorkspaceId;
        createdByMemberId: MemberId;
        workspaceIntegrations: ReadonlyArray<WorkspaceIntegrationToCreate>;
      }): Effect.Effect<
        ReadonlyArray<WorkspaceIntegration>,
        InternalIntegrationModuleError
      >;
    };


In this case I wan't to guarantee that if you pass in an array you get an array back, and if you pass in a single item you get a single item back
Was this page helpful?