Types Not Catching Incorrect Service Dependencies with Layer Merging

Types not catching incorrect service dependencies provided to program, I think I am making a fairly basic error somewhere with merging layers.

Org.get(id: string): Effect<Org, E, OrgService>

DefaultOrgLayer :: Layer<CacheService | OrgService, never, never>
DefaultUserLayer :: Layer<CacheService | UserService, never, never>


Given a program that runs the get function, I can provide either of these layers, only one actually works of course, but I thought the type system would catch this and wonder what I am doing wrong (feels like I am making a basic error somewhere).

const program = (id: string) => Org.get(id)

// Should be a type error?
const output = program('1').pipe(
  Effect.provide(DefaultUserLayer), // Incorrect layer
  Effect.runSync
)


Simplified playground without Cache dependency, this works and TS catches the incorrect dependency: https://effect.website/play/#7b86f52a2d56.

Playground with Cache dependency and layer merging, no TS error even though the service type is incorrect: https://effect.website/play/#c1305ccfdd5c
Was this page helpful?