TypeError: Property 'addEventListener' does not exist on type 'RTCPeerConnection'

I am running into TypeScript errors when working in my Expo/React Native project.

The Problem

Whenever I try to ad event listeners to either RTCPeerConnection or RTCDataChannel, TypeScript says that the property doesn’t exist.

Property 'addEventListener' does not exist on type 'RTCPeerConnection'.
Property 'addEventListener' does not exist on type 'RTCDataChannel'.

Example

const pc = new RTCPeerConnection(config);

pc.addEventListener("icecandidate", (event) => { ... }); // TS error

const dc = pc.createDataChannel("label");
dc.addEventListener("message", (event) => { ... }); // TS error

What I’ve Tried

My Setup

  • Expo SDK 53.0.11
  • react-native-webrtc: 124.0.5
  • typescript 5.8.3

Questions

  • Is anyone else having these issues? If so, did you also create additional type augmentation files to extend the types?
  • If not, how are you accessing the type declarations for these event listeners and event objects?
  • Is there a recommended way to get TypeScript to recognize these event listener methods and event types in react-native-webrtc?

Any help or pointers would be greatly appreciated!

Setting resolvePackageJsonExports to false in tsconfig.json fixed this problem for me