Skip to content

Commit 793a257

Browse files
committed
chore: add stricter typescript and fix type errors
1 parent 07aef74 commit 793a257

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/peer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,10 @@ export default class Peer {
266266
private addDataChannel(channel: RTCDataChannel) {
267267
// setup data channel events
268268
channel.onopen = () => this.emit('channelOpen', { channel });
269-
channel.onerror = (error: RTCErrorEvent) => this.emit('channelError', { channel, error });
269+
channel.onerror = (ev: Event) => {
270+
const event = ev as RTCErrorEvent;
271+
this.emit('channelError', { channel, event });
272+
};
270273
channel.onclose = () => {
271274
this.channels.delete(channel.label);
272275
this.emit('channelClosed', { channel });

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface PeerEvents {
2727
// RTCDataChannel
2828
channelOpen: (data: { channel: RTCDataChannel }) => void;
2929
channelClosed: (data: { channel: RTCDataChannel }) => void;
30-
channelError: (data: { channel: RTCDataChannel; error: RTCErrorEvent }) => void;
30+
channelError: (data: { channel: RTCDataChannel; event: RTCErrorEvent }) => void;
3131
channelData: (data: {
3232
channel: RTCDataChannel;
3333
source: 'incoming' | 'outgoing';

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function randomHex(n: number) {
2020

2121
export const filterTracksAV =
2222
(video: boolean, audio: boolean): FilterTracksFunc =>
23-
(track: MediaStreamTrack) => {
23+
(track) => {
2424
const isVideo = video && track?.kind === 'video';
2525
const isAudio = audio && track?.kind === 'audio';
2626
return isVideo || isAudio;

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"skipLibCheck": true,
88
"sourceMap": true,
99
"stripInternal": true,
10+
"strictBindCallApply": true,
11+
"strictFunctionTypes": true,
1012
"strictNullChecks": true,
1113
"esModuleInterop": true,
1214
"outDir": "dist",

0 commit comments

Comments
 (0)