TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

`RTCDataChannel` `error` event should be of type `RTCErrorEvent`

Open nikwen opened this issue 1 year ago • 0 comments

Code that should compile but doesn't

const peerConnection = new RTCPeerConnection();

peerConnection.addEventListener("datachannel", (event) => {
  event.channel.addEventListener("error", (event) => {
    console.error(event.error);
  });
});

TypeScript complains: "TS2339: Property error does not exist on type Event"

Reason

The RTCDataChannel error event should be of type RTCErrorEvent. In the type declarations, it's of type Error.

Reference

  • https://www.w3.org/TR/webrtc/#event-datachannel-error
  • https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/error_event

nikwen avatar Aug 23 '24 12:08 nikwen