Skip to content

events: type of eventName allowed besides string/symbol #31331

Closed

Description

@Flarna
  • Version: 13.6.0
  • Platform: all
  • Subsystem: events

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

  1. himself65 commented on Jan 13, 2020

    @himself65
    Member

    I think we shouldn’t tell people they could do that, even we support. And that commit just for backwards compatibility for other libraries.

  2. cjihrig commented on Jan 13, 2020

    @cjihrig
    Contributor

    FWIW, I tried to add type validation in #21007. I can revisit that if we actually want that validation.

  3. Flarna commented on Jan 16, 2020

    @Flarna
    MemberAuthor

    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.

  4. devsnek commented on Jan 16, 2020

    @devsnek
    Member

    I'd +1 some better type checking here.

  5. Flarna commented on Feb 5, 2020

    @Flarna
    MemberAuthor

    Perf impact of type checks seems to be too high, see #31428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions