Effect CommunityEC
Effect Community4w ago
7 replies
min

Extracting Interface Type from `Effect.Service` Implementation

There are a couple of ways to extract the underlying interface type of a service represented using Context.Tag.

For example:
class TestService extends ContextTag('TestService')<
  TestService,
  {
    doSomething: (x: string) => Effect.Effect<string>
    getData: () => Effect.Effect<number>
  },
})> {} ... some implementation

type MyInterface = TestService['Type']
type RandomShape = Context.Tag.Service<TestService>


Is there a way to do this if the service is implemented straight away using Effect.Service ?
class TestService extends Effect.Service<TestService>()('TestService', {
  effect: Effect.succeed({
    doSomething: (x: string) => Effect.succeed(x),
    getData: () => Effect.succeed(42),
  }),
}) {}
Was this page helpful?