Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript error in FakeRTCDataChannel #24

Open
ibc opened this issue Sep 14, 2023 · 0 comments
Open

TypeScript error in FakeRTCDataChannel #24

ibc opened this issue Sep 14, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ibc
Copy link
Member

ibc commented Sep 14, 2023

src/FakeRTCDataChannel.ts:23:14 - error TS2420: Class 'FakeRTCDataChannel' incorrectly implements interface 'RTCDataChannel'.
  Types of property 'addEventListener' are incompatible.
    Type '{ <T extends string>(type: T, callback?: EventListener<this, Event<string>> | null | undefined, options?: AddOptions | undefined): void; (type: string, callback?: EventListener<...> | ... 1 more ... | undefined, options?: AddOptions | undefined): void; <T extends string>(type: T, callback: EventListener<...> | ... 1...' is not assignable to type '{ <K extends keyof RTCDataChannelEventMap>(type: K, listener: (this: RTCDataChannel, ev: RTCDataChannelEventMap[K]) => any, options?: boolean | ... 1 more ... | undefined): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | ... 1 more ... | undefined): void; }'.
      Types of parameters 'callback' and 'listener' are incompatible.
        Type '(this: RTCDataChannel, ev: any) => any' is not assignable to type 'EventListener<this, Event<string>> | null | undefined'.
          Type '(this: RTCDataChannel, ev: any) => any' is not assignable to type 'CallbackFunction<this, Event<string>>'.
            The 'this' types of each signature are incompatible.
              Type 'this' is not assignable to type 'RTCDataChannel'.
                Type 'FakeRTCDataChannel' is not assignable to type 'RTCDataChannel'.
                  Types of property 'addEventListener' are incompatible.
                    Type '{ <T extends string>(type: T, callback?: EventListener<this, Event<string>> | null | undefined, options?: AddOptions | undefined): void; (type: string, callback?: EventListener<...> | ... 1 more ... | undefined, options?: AddOptions | undefined): void; <T extends string>(type: T, callback: EventListener<...> | ... 1...' is not assignable to type '{ <K extends keyof RTCDataChannelEventMap>(type: K, listener: (this: RTCDataChannel, ev: RTCDataChannelEventMap[K]) => any, options?: boolean | ... 1 more ... | undefined): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | ... 1 more ... | undefined): void; }'.
                      Types of parameters 'callback' and 'listener' are incompatible.
                        Type '(this: RTCDataChannel, ev: any) => any' is not assignable to type 'EventListener<this, Event<string>> | null | undefined'.

23 export class FakeRTCDataChannel extends EventTarget implements RTCDataChannel

This is currently "workarounded" with a @ts-ignore above FakeRTCDataChannel class definition and also another 2 @ts-ignore in Handler.ts, which is hell ofc.

Problem is that mediasoup-client relies on "dom" TS library, and here we are defining FakeRTCDataChannel which uses event-target-shim dep to mimics DOM's EventTarget. Related task in mediasoup-client: versatica/mediasoup-client#279

@ibc ibc added the bug Something isn't working label Sep 14, 2023
@ibc ibc mentioned this issue Sep 14, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant