TypeScript-DOM-lib-generator
TypeScript-DOM-lib-generator copied to clipboard
`RTCDataChannel` `error` event should be of type `RTCErrorEvent`
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