At times, there may be a situation where we need to omit the generic variable. For example:
@Component( ... )
class MyComponent {
@Output()
public cancel = new EventEmitter<undefined>();
private myFoo() {
this.cancel.emit(); // no value needs to be passed
}
}
Now, here comes the question: What is the better way to define the EventEmitter type?
EventEmitter<undefined>
or EventEmitter<void>
.
void
is preferable because no argument is required in the.emit()
method call.undefined
is better as.emit()
functions similarly to.emit(undefined)
.
What are your thoughts on this matter?