Type Inference Issue with `Effect.fn` in Service Definition
Effect.fn not inferring types
they both return same type, which one should I use?
export class Service1 extends Context.Tag("Service1")<
Service1,
{
createTodo: (content: string) => Effect.Effect<string>;
}
>() {}
const LiveService1 = Layer.effect(
Service1,
Effect.gen(function* () {
return {
createTodo: (content) => {// type of content is string
return Effect.gen(function* () {
return "hello";
});
},
};
}),
);
const LiveService2 = Layer.effect(
Service1,
Effect.gen(function* () {
return {
createTodo: Effect.fn(function* (content) { // type of content is any
return "hello";
}),
};
}),
);export class Service1 extends Context.Tag("Service1")<
Service1,
{
createTodo: (content: string) => Effect.Effect<string>;
}
>() {}
const LiveService1 = Layer.effect(
Service1,
Effect.gen(function* () {
return {
createTodo: (content) => {// type of content is string
return Effect.gen(function* () {
return "hello";
});
},
};
}),
);
const LiveService2 = Layer.effect(
Service1,
Effect.gen(function* () {
return {
createTodo: Effect.fn(function* (content) { // type of content is any
return "hello";
}),
};
}),
);they both return same type, which one should I use?
