Effect CommunityEC
Effect Community•3y ago•
279 replies
Kristian Notari

"Service Not Found" Error and Tags in TypeScript

I have a questions about "service not found" error and tags: I thought that when creating:
const tagA1 = Context.Tag<"A", T>()
const tagA2 = Context.Tag<"A", T>()

requiring one and providing the other worked correctly, but it turns out it can't find the service, cause those are two different tags.

Can you confirm me that's the reason?

I then proceeded adding a specificy key to both:
const tagA1 = Context.Tag<"A", T>("A")
const tagA2 = Context.Tag<"A", T>("A")

And then it worked correctly.

My real question is: since my tag1-related service (T1) is being required by another service (T2) (T1 is a service dependency for T2 and I need T2) I need to provide T1 in order to get T2. I have tag2 in my codebase, but not tag1. Is there a way to provide the same service if I can't edit the key for tag1 as I did in the last example?
// code from library not exported
const tagA1 = Context.Tag<"A", T>()

// my code
const tagA2 = Context.Tag<"A", T>(/* ??? */)
Was this page helpful?