Skip to content

Commit

Permalink
fix: improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed Jan 23, 2025
1 parent 421a60c commit 7eff736
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/api/WebSocketAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ class WebSocketAPI {

open?: boolean;

requests!: WebSocketAPIRequest[];
requests!: WebSocketAPIRequest<unknown>[];

subscribed!: WebSocketAPISubscribed;

subscriptions!: WebSocketAPISubscription[];
subscriptions!: WebSocketAPISubscription<unknown>[];

websocket?: WebSocket;

Expand Down Expand Up @@ -291,8 +291,10 @@ class WebSocketAPI {
requestString,
};
if (index > -1) {
// @ts-expect-error - We know that the requests is an array of WebSocketAPIRequest
this.requests[index] = newReq;
} else {
// @ts-expect-error - We know that the requests is an array of WebSocketAPIRequest
this.requests.push(newReq);
}
}
Expand Down Expand Up @@ -336,6 +338,7 @@ class WebSocketAPI {
let contents: WebSocketAPIMessageEventData<T>[];

if (data.source === 'buffer') {
// @ts-expect-error - We know that the data is a WebSocketAPIBufferMessageEventData
contents = (data as unknown as WebSocketAPIBufferMessageEventData)
.content;
} else {
Expand Down Expand Up @@ -424,8 +427,10 @@ class WebSocketAPI {
);
const newSubscr = { cb, errorCb, onErrorCb, onMessageCb, params, quiet };
if (index > -1) {
// @ts-expect-error - We know that the subscriptions is an array of WebSocketAPISubscription
this.subscriptions[index] = newSubscr;
} else {
// @ts-expect-error - We know that the subscriptions is an array of WebSocketAPISubscription
this.subscriptions.push(newSubscr);
}

Expand Down

0 comments on commit 7eff736

Please sign in to comment.