Using Generics with Context Tags in TypeScript

Hello!!
I’m struggling with services and generics in TypeScript. How can I create a Tag while using generics? How would the following example work? Defining a Tag with random generic types feels absolutely wrong... what is the proper way of using Tags and Generics? 😅
import { Context, Effect, Schema } from 'effect'
import { Line } from '../types'

export interface Service<T, I> {
  readonly schema: Schema.Schema<Line<T>, I>
  readonly processValidLine: (validLine: Line<T>) => Effect.Effect<unknown>
}

export class Tag extends Context.Tag('@service')<
  Tag,
  Service<
    {
      [key: string]: unknown
    },
    {
      [key: string]: unknown
    }
  >
>() {}
`
Was this page helpful?