void as a type of an argument of a generic function in TypeScript

前端 未结 7 1312
遥遥无期
遥遥无期 2021-01-11 09:37

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

7条回答
  •  无人及你
    2021-01-11 09:55

    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:

    var voidValue = (function () { })();
    

提交回复
热议问题