Repository navigation
refactor(effect)!: clean up public type surface before stable - #2320
Conversation
- HandlerGen/handlerGen follow ProcedureHandler order with TYield last, and handlerGen gets defaults like middlewareGen; add AnyHandlerGen - MiddlewareGen moves TYield last to match middlewareGen - InferEffectServices no longer distributes over union contexts - Remove InferYieldError - Stop exporting runtime.ts (runPromise, RunPromiseOptions) and schema.ts (toStandardSchema); the docs keep Effect's native Schema.toStandardSchemaV1 BREAKING CHANGE: HandlerGen, handlerGen and MiddlewareGen type parameter order changed; InferYieldError, runPromise, RunPromiseOptions and toStandardSchema are no longer exported; InferEffectServices of a union context only includes services every member provides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EJQNgdewgQDKw3FvMx6svZ
87426ae to
d0aec58
Compare
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This PR intentionally makes breaking public-contract changes to the Effect package, including removing root exports and reordering public generic parameters, while also changing union-context type inference. Internal handler execution remains largely unchanged, but existing consumers may require source updates, so the compatibility impact merits human review. Notes:
You can add or adjust custom eligibility rules. Learn more. |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/mcp
@orpc/msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the pre-stable type-surface cleanup of @orpc/experimental-effect; I read the full diff and verified the package tests (pnpm vitest run packages/effect, 106 passing) plus the full root tsc, which type-checks the *.test-d.ts assertions this PR relies on.
- Consistent generic order (
TYieldlast) —HandlerGen,handlerGenandMiddlewareGennow mirrorProcedureHandler/Middleware; every internal call site (extensions/effect.ts, the extensionHandlerGenarguments, the type tests) was updated in lockstep. Breaking only for explicit type arguments. handlerGendefaults —TInput/TReturn=unknown, empty error map, and aTYielddefault identical tomiddlewareGen, so a standalone handler works with only the context. Backed by a new type test.InferEffectServicesis non-distributive —[T] extends [{ 'effect/context': Context<infer S> }] ? S : neverrestricts a union context to services every member provides (neverfor disjoint services). New tests cover union, intersection andanycontexts, and the doc comment was updated to match.- Removed exports —
InferYieldError,runPromise,RunPromiseOptions,toStandardSchema(and the./runtime/./schemare-exports).runtime.ts/schema.tsremain internal and are still exercised via direct-path unit tests;index.test.tsnow asserts the helpers are absent from the public module. No remaining repo references to any removed symbol. AnyHandlerGenadded alongside the existingAnyMiddlewareGen.
The one internal loss of precision — handler.ts:44 now casts to Effect.Effect<TReturn, unknown> rather than InferYieldError<TYield> — is not observable: both runPromise and effect/wrap already accept Effect<..., unknown>, so no public signature changes. Docs already use Effect's native Schema.toStandardSchemaV1 and never reference the removed exports or an explicit generic order.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance1 warning, 1 note
Comparing Footnotes
|

Cleans up the public type surface of
@orpc/experimental-effectbefore it is promoted to stable, since each change becomes breaking afterwards.Changes
HandlerGen/handlerGenfollowProcedureHandlerorder withTYieldlast:<TCurrentContext, TInput, TReturn, TErrorConstructorMap, TYield>.handlerGengets defaults likemiddlewareGen, andAnyHandlerGenis added.MiddlewareGenmovesTYieldlast to matchmiddlewareGen.InferEffectServicesno longer distributes over union contexts, so a handler can't yield a service that some members don't provide:WithEffectContext<A> | WithEffectContext<B>A | BneverWithEffectContext<A> | { auth: boolean }AneverWithEffectContext<A | B> | WithEffectContext<A>A | BAWithEffectContext<A> & { auth: boolean }AAanyunknownunknownInferYieldErroris removed; use Effect'sEffect.Error<T>.runtime.ts(runPromise,RunPromiseOptions) andschema.ts(toStandardSchema) are no longer exported. Both stay internal; the docs keep Effect's nativeSchema.toStandardSchemaV1.The
'effect/context'/'effect/wrap'string keys are intentionally kept.Breaking changes
HandlerGen,handlerGenandMiddlewareGentype parameter order changed (only affects explicit type arguments).InferYieldError,runPromise,RunPromiseOptionsandtoStandardSchemaare no longer exported.InferEffectServicesof a union context only includes services every member provides.Tests
handler.test-d.ts/middleware.test-d.ts: explicit type arguments lock the new order;handlerGendefaults are checked.context.test-d.ts: union, intersection andanycontexts.index.test.ts: asserts the internal helpers are not exported.Verified locally on this commit:
pnpm vitest run packages/effect, the effect package type check,pnpm lintandpnpm docs:validate. The fullpnpm type:checkruns in CI.🤖 Generated with Claude Code
https://claude.ai/code/session_01EJQNgdewgQDKw3FvMx6svZ