Skip to content

Bug: Support for Symbol for fromEvent #7338

@Lightning00Blade

Description

@Lightning00Blade

Describe the bug

Node Event Emitter supports Symbol for on/off https://nodejs.org/api/events.html#emitteroneventname-listener.
The current implementation of RxJS can use them as provided the example bellow it's just that the types that are used don't support them.

Expected behavior

Symbols are accepted as types.

Reproduction code

import { fromEvent } from 'rxjs';
import { EventEmitter } from 'node:events';

const emitter = new EventEmitter();
const protectedEvent = Symbol('Emitted');

// Fails  TypeChecking
const sourceOne = fromEvent(emitter, protectedEvent);
// Passes TypeChecking
const sourceTwo = fromEvent(emitter, protectedEvent as unknown as string);

sourceOne.subscribe((val) => console.log(val));
sourceTwo.subscribe((val) => console.log(val));

emitter.emit(protectedEvent, {
  message: 'Hello World',
});

Reproduction URL

No response

Version

7.8.1

Environment

Node: 20.3.1 (should work for 16 LTS and above)

Additional context

This useful so that you can have internal methods not exposed the the user of libary.

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