From c09ef1de2b1ee23a6ceb4ea8faf0e0ee091a274d Mon Sep 17 00:00:00 2001 From: Sam Goodwin Date: Fri, 17 Jul 2026 13:34:17 -0700 Subject: [PATCH] fix(cloudflare-runtime): annotate RemoteWorker make/layer so dts keeps typed error/requirement channels The dts bundler cannot name the inferred Credentials requirement from @distilled.cloud/cloudflare and degraded make/layer (and everything composed from them, e.g. RuntimeServices.layerRuntime) to any/any. Co-Authored-By: Claude Fable 5 --- .../src/remote-bindings/RemoteWorker.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/cloudflare-runtime/src/remote-bindings/RemoteWorker.ts b/packages/cloudflare-runtime/src/remote-bindings/RemoteWorker.ts index ec8816f1..a1900d7b 100644 --- a/packages/cloudflare-runtime/src/remote-bindings/RemoteWorker.ts +++ b/packages/cloudflare-runtime/src/remote-bindings/RemoteWorker.ts @@ -1,3 +1,4 @@ +import type { Credentials } from "@distilled.cloud/cloudflare/Credentials"; import * as workers from "@distilled.cloud/cloudflare/workers"; import * as Cause from "effect/Cause"; import * as Context from "effect/Context"; @@ -20,7 +21,17 @@ export class RemoteWorker extends Context.Service< } >()("cloudflare-runtime/remote-bindings/RemoteWorker") {} -export const make = Effect.fn(function* (accountId: Effect.Effect) { +// Explicit annotation: the inferred type references `Credentials` from +// `@distilled.cloud/cloudflare`, which the dts bundler cannot name on its +// own — without this it degrades `make`/`layer` (and everything composed +// from them, e.g. `RuntimeServices.layerRuntime`) to `any, any`. +export const make: ( + accountId: Effect.Effect, +) => Effect.Effect< + RemoteWorker["Service"], + never, + Access.Access | Credentials | HttpClient.HttpClient +> = Effect.fn(function* (accountId: Effect.Effect) { const http = yield* HttpClient.HttpClient; const access = yield* Access.Access; @@ -123,7 +134,9 @@ export const make = Effect.fn(function* (accountId: Effect.Effect) { }); }); -export const layer = (accountId: Effect.Effect) => +export const layer = ( + accountId: Effect.Effect, +): Layer.Layer => Layer.effect(RemoteWorker, make(accountId)); /**