Open kevinresol opened 10 months ago
This behavior is expected. In order to support this we would need to distribute unions in the input type even without using .exhaustive()
and this is pretty expensive in terms of type checking time.
See the discussion in issue https://github.com/gvergnaud/ts-pattern/issues/145 for some additional context on how type narrowing and exhaustive work in ts-pattern
Describe the bug In the code below, all occurrences of
v1
andv2
are inferred asstring | undefined
but in fact they should bestring
because the undefined cases are already handled.In fact, it works if the pattern is a single value instead of a tuple:
Code Sandbox with a minimal reproduction case https://codesandbox.io/p/sandbox/crazy-galileo-3zsfmh
Versions