You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
events: type of eventName allowed besides string/symbol #31331
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 0468861).
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.
Activity
himself65 commentedon Jan 13, 2020
I think we shouldn’t tell people they could do that, even we support. And that commit just for
backwards compatibility for other libraries.cjihrig commentedon Jan 13, 2020
FWIW, I tried to add type validation in #21007. I can revisit that if we actually want that validation.
Flarna commentedon Jan 16, 2020
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.
devsnek commentedon Jan 16, 2020
I'd +1 some better type checking here.
Flarna commentedon Feb 5, 2020
Perf impact of type checks seems to be too high, see #31428