Uncaught Error: Type “function MediaStream() { [native code] }” not yet supported in PeerJS

I’m working on a video conferencing application using PeerJS, and I’m encountering an issue when trying to pass a video stream to another peer. The error I’m getting is:

Uncaught Error: Type "function MediaStream() { [native code] }" not yet supported

Here are the relevant parts of my code:
Peer.ts

addStream(stream: MediaStream) {
    console.log('Adding stream to peers:', stream);
    Object.values(this.peers).forEach(peer => {
        const call = this.peer.call(peer.conn.peer, stream, {
            metadata: { username: 'Video', video: true, audio: true }
        });

        call.on('stream', peerStream => {
            console.log('Received peer stream:', peerStream);
            this.emit('peer', {
                id: call.peer,
                username: 'Video',
                stream: peerStream,
                video: true,
                audio: true
            });
        });

        this.peers[peer.conn.peer].media = call;
    });

    this.emit('peer', {
        id: 'video',
        username: 'Video',
        stream: stream,
        video: true,
        audio: true
    });

    // Emit an event to notify peers
    Object.values(this.peers).forEach(peer => {
        if (peer.conn) {
            peer.conn.send({
                type: 'add-stream',
                data: { streamId: STATIC_STREAM_ID } // Use static stream ID
            });
        }
    });
}

handleAddStream(streamId: string) {
    console.log('Handling added stream:', streamId);
    if (streamId === STATIC_STREAM_ID) {
        const stream = this.hostStream;

        if (stream) {
            console.log('Stream found:', stream);
            this.emit('peer', {
                id: 'video',
                username: 'Video',
                stream: mediaStream,
                video: true,
                audio: true
            });
        } else {
            console.error('Stream not found:', streamId);
        }
    } else {
        console.error('Invalid stream ID:', streamId);
    }
}

Host.ts:

addStream(stream: MediaStream) {
    console.log('Adding stream to peers:', stream);
    Object.values(this.peers).forEach(peer => {
        const call = this.peer.call(peer.conn.peer, stream, {
            metadata: { username: 'Video', video: true, audio: true }
        });

        call.on('stream', stream => {
            console.log('Received peer stream:', stream);
            this.emit('peer', {
                id: STATIC_STREAM_ID,
                username: 'Video',
                stream: stream,
                video: true,
                audio: true
            });
        });

        this.peers[peer.conn.peer].media = call;
    });

    console.log('Added stream to peers:', stream);
    this.emit('peer', {
        id: 'video',
        username: 'Video',
        stream: stream,
        video: true,
        audio: true
    });
    this.passSpecialString(stream.id)
    this.passMediaStream(stream);

    // Emit an event to notify peers
    Object.values(this.peers).forEach(peer => {
        if (peer.conn) {
            peer.conn.send({
                type: 'add-stream',
                data: { streamId: STATIC_STREAM_ID } // Use static stream ID
            });
        }
    });
}

passMediaStream(mediaStream: MediaStream) {
    Object.values(this.peers).forEach(peer => {
        if (peer.conn) {
            peer.conn.send({
                type: 'media-stream',
                data: { stream: mediaStream }
            });
        }
    });
}

I’ve tried to ensure that the MediaStream object is correctly passed and handled, but I keep encountering this error. Any insights on what might be causing this issue and how to resolve it would be greatly appreciated.