Really weird TypeScript behavior

Hey. I have this really weird type inference error. So the types do get inferred correctly, as you can see in the first screenshot below. However, when I actually want to call the function the types disappear and become type never 👀 The type inference correctly picks up the fact that the function parameters can either be "1" and no arguments, or "2" and no arguments.
6 Replies
domi?
domi?2y ago
However, when I actually want to specify those arguments, the types become type never:
domi?
domi?2y ago
Weirdly enough, when I remove an object from the Routes type array, everything works correctly:
domi?
domi?2y ago
Update: I managed to solve the issue. I converted the type of send from a union to an intersection. That created overloads for the send function and everything works now 👍
Want results from more Discord servers?
Add your server