Skip to content

Would there be any way to make this merge function work? #279

Answered by gvergnaud
scarf005 asked this question in Q&A
Discussion options

You must be logged in to vote

It's a known limitation that TS-Pattern doesn't handle matching on type parameters very well. That's because TypeScript inference gets stuck on unknown type parameters, and there is unfortunately nothing we can do about it in userland.

You can work around this by using an overload for your merge function: Playground

This also works, but is more brittle because it relies on implementation details of the way inference works (if you don't use parameters, their types dont get evaluated): Playground

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by scarf005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants