Fixing "any" type

This commit is contained in:
David Négrier 2020-09-15 10:10:35 +02:00
parent 9b702c75e3
commit f8d462b0d7
4 changed files with 9 additions and 9 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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<Zone>(),
} 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<Zone>(),
} as UserInterface;
let user2 = {
const user2 = {
id: "2",
position: {
x: -9999,

View File

@ -111,7 +111,7 @@ export interface UserMovesInterface {
export interface BatchedMessageInterface {
event: string,
payload: any
payload: unknown
}
export class Connection implements Connection {