Some time ago I was struggling with TypeScript generic types and decided to reach for help from smarter guys on Stack Overflow. I received an answer, thanks! The solution is based on very specific conditional type which I was not familiar with back then,… and I’m probably still not. But, there is a one truly helpful talk by Gregor Woiwode describing the matter of this TypeScript magic. I really recommend you to watch if you want to understand it better.