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

前端 未结 7 1294
遥遥无期
遥遥无期 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条回答
  •  旧时难觅i
    2021-01-11 09:58

    From the TypeScript specification:

    NOTE: We might consider disallowing declaring variables of type Void as they serve no useful purpose. However, because Void is permitted as a type argument to a generic type or function it is not feasible to disallow Void properties or parameters.

提交回复
热议问题