Skip to content

Commit

Permalink
default to never for Runtime returning functions (#2096)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Feb 10, 2024
1 parent 2eb11b4 commit 6654f5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .changeset/brave-rats-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"effect": patch
---

default to `never` for Runtime returning functions

This includes:

- Effect.runtime
- FiberSet.makeRuntime

It prevents `unknown` from creeping into types, as well as `never` being a
useful default type for propogating Fiber Refs and other context.
2 changes: 1 addition & 1 deletion packages/effect/src/Effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,7 @@ export const randomWith: <A, E, R>(f: (random: Random.Random) => Effect<A, E, R>
* @since 2.0.0
* @category runtime
*/
export const runtime: <R>() => Effect<Runtime.Runtime<R>, never, R> = _runtime.runtime
export const runtime: <R = never>() => Effect<Runtime.Runtime<R>, never, R> = _runtime.runtime

/**
* Retrieves an effect that succeeds with the current runtime flags, which
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/FiberSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const make = <A = unknown, E = unknown>(): Effect.Effect<FiberSet<A, E>,
* @since 2.0.0
* @categories constructors
*/
export const makeRuntime = <R, A = unknown, E = unknown>(): Effect.Effect<
export const makeRuntime = <R = never, A = unknown, E = unknown>(): Effect.Effect<
<XE extends E, XA extends A>(
effect: Effect.Effect<XA, XE, R>,
options?: Runtime.RunForkOptions | undefined
Expand Down

0 comments on commit 6654f5f

Please sign in to comment.