Curious about this topic. I am seeking a definitive answer to clarify my understanding.
My goal is to specify to the compiler/language service/reader that T
should be absolutely nothing, empty, or null. I am unsure whether void
, never
, or undefined
is the most appropriate choice.
// indicating that there should be no props available
class MyComponent extends React.Component<???, any> { ... }
// indicating that the Promise should resolve to nothing
function foo(): Promise<???> { ... }
(If you can think of other scenarios where void
, never
, or undefined
should be used in generics, please let me know so I can add them to this list)
Related questions: What is the difference between never and void in typescript?
Based on the information from the above link and the response from @mierion-hughes, it appears that never
is straightforward. The remaining dilemma is between void
and undefined
.