Skip to content

Commit

Permalink
feat: add runtime type extractor (#4020)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinassefranche authored and gcanti committed Dec 10, 2024
1 parent 8adcd7e commit 52a4b66
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-rocks-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

Add Runtime.Runtime.Context type extractor
4 changes: 4 additions & 0 deletions packages/effect/dtslint/Runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type * as Runtime from "effect/Runtime"

// $ExpectType { foo: string; }
export type ContextOfRuntime = Runtime.Runtime.Context<Runtime.Runtime<{ foo: string }>>
11 changes: 11 additions & 0 deletions packages/effect/src/Runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ export interface Runtime<in R> extends Pipeable {
readonly fiberRefs: FiberRefs.FiberRefs
}

/**
* @since 3.12.0
*/
export declare namespace Runtime {
/**
* @since 3.12.0
* @category Type Extractors
*/
export type Context<T extends Runtime<any>> = [T] extends [Runtime<infer R>] ? R : never
}

/**
* @since 2.0.0
* @category models
Expand Down

0 comments on commit 52a4b66

Please sign in to comment.