You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that if statically known at implementation time, I could use catchTags or catchAll.
But when the predicate changes based on external input and the implementation is independent of it, the input change affecting the predicate will require a change in the implementation. It is unexpected behavior and need to be tracked down.
akomm
changed the title
CatchIf - predicate that is always true or false does not Exclude<...> error types correctly
CatchIf - predicate that is always true does not Exclude<...> error types correctly
Dec 16, 2024
Unfortunately in cases where the check doesn't reduce the input TS doesn't infer a type predicate, unsure about the choice on the TS side but we have no control over it
What version of Effect is running?
3.11.6
What steps can reproduce the bug?
Code is based on Effect-TS Example for catchif
Open the code below in TS-Playground
What is the expected behavior?
The inferred type of
const recovered
should beEffect<string, never, never>
What do you see instead?
Effect<string, HttpError | ValidationError, never>
Additional information
When a function does not narrow down the input, its not inferred as a type predicate: microsoft/TypeScript#60741 (comment)
This cause non-linear behavior in
catchIf
.I know that if statically known at implementation time, I could use
catchTags
orcatchAll
.But when the predicate changes based on external input and the implementation is independent of it, the input change affecting the predicate will require a change in the implementation. It is unexpected behavior and need to be tracked down.
Here is a suggestion adding an overload for this case: microsoft/TypeScript#60741 (comment)
The text was updated successfully, but these errors were encountered: