It is possible to specify void as a type parameter for generic function in TypeScript. And it works fine for return values of functions. However when void
It turned out it's very easy to get a value of void. Although technically it is still the undefined value, but TypeScript believes it's of the type void which is exactly what we need: