Docs tell that eventName should be of type string or symbol. But actually there is no type check and it works to use e.g. number, function or null - they just get coerced to a string (which is quite nice for functions).
There are also two tests which use non string/symbol: e.g. test-event-emitter-max-listeners-warning-for-null.js and test-event-emitter-subclass.js.
Are the docs wrong or the implementation? Or is this just some relict which can't be changed but should be hidden in docs as there were already type checks implemented (see https://github.com/nodejs/node/commit/04688614f70470dba1f7512844fd2c4008d9d8bd).
Edit:
Maybe some more background on this: I worked on adding typechecks for types and at that time I discovered a few failing tests and as followup the commit linked above.
I think we shouldn鈥檛 tell people they could do that, even we support. And that commit just for backwards compatibility for other libraries.
FWIW, I tried to add type validation in https://github.com/nodejs/node/pull/21007. I can revisit that if we actually want that validation.
Seems like this is an area which should not be touched. There were already type checks which got removed and a later try to add them was given up.
I'd +1 some better type checking here.
Perf impact of type checks seems to be too high, see #31428
Most helpful comment
FWIW, I tried to add type validation in https://github.com/nodejs/node/pull/21007. I can revisit that if we actually want that validation.