Summary
A user seems to be experiencing a potential bug when using the Effect Typescript library with the HttpMiddleware and Effect.fn constructs. They have shared some TypeScript code snippets to demonstrate the issue:
-
In the first example, they use HttpMiddleware.make with Effect.gen and an arrow function. This works as expected.
const example = HttpMiddleware.make((app) =>
Effect.gen(function* () {
return yield* app;
})
);
-
In the second example, they attempt to use HttpMiddleware.make with Effect.fn in conjunction with a named generator function, but it shows any for example2.
const example2 = HttpMiddleware.make(
Effect.fn(function* (app) {
return yield* app;
})
);
Key takeaways:
- The issue arises when using
Effect.fn with a named function, which results in the type being inferred as any.
- The TypeScript version being used is 5.9.2, which is the latest at the time of this discussion.
- It seems there might be a typing or compatibility issue with
Effect.fn when the structure of the function changes from an arrow function to a named generator function.
- The user is encouraged to provide a reproducible example to better diagnose the issue.
Discord thread
https://discord.com/channels/795981131316985866/1405386313703751740
Summary
A user seems to be experiencing a potential bug when using the Effect Typescript library with the
HttpMiddlewareandEffect.fnconstructs. They have shared some TypeScript code snippets to demonstrate the issue:In the first example, they use
HttpMiddleware.makewithEffect.genand an arrow function. This works as expected.In the second example, they attempt to use
HttpMiddleware.makewithEffect.fnin conjunction with a named generator function, but it showsanyforexample2.Key takeaways:
Effect.fnwith a named function, which results in the type being inferred asany.Effect.fnwhen the structure of the function changes from an arrow function to a named generator function.Discord thread
https://discord.com/channels/795981131316985866/1405386313703751740