Implementing an Alternative `Effect.Service` Requires the `_tag` Property

When defining a service using
Context.Tag
, I can implement it by implementing the methods only. However to create an alternative implementation of an Effect.Service I also need to implement the
_tag
property.
export class DemoTag extends Context.Tag("@demoTag")<
  DemoTag,
  {
    getName: () => Effect.Effect<string>
  }
>() {}

const stubbedTag = Layer.succeed(DemoTag, { 
  getName: () => Effect.succeed("stubbed")
})

export class DemoService extends Effect.Service<DemoService>()("@demoService", {
  effect: Effect.gen(function* () {
    return {
      getName: () => Effect.succeed("live"),
    };
  }),
}) {}

const stubbedService = Layer.succeed(DemoService, { 
  // why do i need this?
  _tag: "@demoService",
  getName: () => Effect.succeed("stubbed")
})

Is this the correct way of creating an alternative implementation?
Was this page helpful?