From f8d462b0d7231bc244b95b87983103e9d512b31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 15 Sep 2020 10:10:35 +0200 Subject: [PATCH] Fixing "any" type --- back/src/Controller/IoSocketController.ts | 4 ++-- back/src/Model/Websocket/ExSocketInterface.ts | 4 ++-- back/tests/PositionNotifierTest.ts | 8 ++++---- front/src/Connection.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 228a0da8..e18a5beb 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -41,7 +41,7 @@ enum SockerIoEvent { BATCH = "batch", } -function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: any): void { +function emitInBatch(socket: ExSocketInterface, event: string | symbol, payload: unknown): void { socket.batchedMessages.push({ event, payload}); if (socket.batchTimeout === null) { @@ -169,7 +169,7 @@ export class IoSocketController { const client : ExSocketInterface = socket as ExSocketInterface; client.batchedMessages = []; client.batchTimeout = null; - client.emitInBatch = (event: string | symbol, payload: any): void => { + client.emitInBatch = (event: string | symbol, payload: unknown): void => { emitInBatch(client, event, payload); } this.sockets.set(client.userId, client); diff --git a/back/src/Model/Websocket/ExSocketInterface.ts b/back/src/Model/Websocket/ExSocketInterface.ts index c5132eb7..bbe18cbb 100644 --- a/back/src/Model/Websocket/ExSocketInterface.ts +++ b/back/src/Model/Websocket/ExSocketInterface.ts @@ -17,7 +17,7 @@ export interface ExSocketInterface extends Socket, Identificable { /** * Pushes an event that will be sent in the next batch of events */ - emitInBatch: (event: string | symbol, payload: any) => void; - batchedMessages: Array<{ event: string | symbol, payload: any }>; + emitInBatch: (event: string | symbol, payload: unknown) => void; + batchedMessages: Array<{ event: string | symbol, payload: unknown }>; batchTimeout: NodeJS.Timeout|null; } diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index 833852b0..ac82878b 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -32,7 +32,7 @@ describe("PositionNotifier", () => { leaveTriggered = true; }); - let user1 = { + const user1 = { id: "1", position: { x: 500, @@ -43,7 +43,7 @@ describe("PositionNotifier", () => { listenedZones: new Set(), } as UserInterface; - let user2 = { + const user2 = { id: "2", position: { x: -9999, @@ -117,7 +117,7 @@ describe("PositionNotifier", () => { leaveTriggered = true; }); - let user1 = { + const user1 = { id: "1", position: { x: 500, @@ -128,7 +128,7 @@ describe("PositionNotifier", () => { listenedZones: new Set(), } as UserInterface; - let user2 = { + const user2 = { id: "2", position: { x: -9999, diff --git a/front/src/Connection.ts b/front/src/Connection.ts index fd06329d..c04e5b4f 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -111,7 +111,7 @@ export interface UserMovesInterface { export interface BatchedMessageInterface { event: string, - payload: any + payload: unknown } export class Connection implements Connection {