1
0

🔧 Add tsconfig and fix some TS errors

This commit is contained in:
2022-01-06 18:21:16 +01:00
parent 931cc57b1b
commit 044d697b15
3 changed files with 34 additions and 18 deletions

View File

@@ -1,10 +1,11 @@
import * as WebSocket from "ws";
import * as express from "express";
import { AddressInfo, Socket } from "net";
import { IncomingMessage, Server } from "http";
import { save, scheduledActions } from "./miniDb";
import { Action } from "../../interfaces/actions/Action";
import WebSocket from "ws";
import express from "express";
import { handleClientAction } from "../chatClient";
import { isDevelopment } from "./util";
import { join } from "path";
@@ -73,7 +74,7 @@ function onListening() {
}
function onUpgrade(req: IncomingMessage, socket: Socket, head: Buffer) {
wsServer.handleUpgrade(req, socket, head, (socket) => {
wsServer.handleUpgrade(req, socket, head, (socket: WebSocket) => {
wsServer.emit("connection", socket, req);
});
}

View File

@@ -41,24 +41,17 @@ async function russianRoulette(
// eslint-disable-next-line require-atomic-updates
msg.message = win ? "" : "got shot";
const promises: Array<Promise<unknown>> = [];
try {
if (!win) {
promises.push(
timeout(channel, userDisplayName, timeoutSeconds, "F en la ruleta")
);
promises.push(
say(
await timeout(channel, userDisplayName, timeoutSeconds, "F en la ruleta");
await say(
channel,
`PepeHands ${userDisplayName} no ha sobrevivido para contarlo`
)
);
} else {
promises.push(say(channel, `rdCool Clap ${userDisplayName}`));
await say(channel, `rdCool Clap ${userDisplayName}`);
}
try {
await Promise.allSettled(promises);
} catch (e) {
if (e instanceof Error) {
console.log(`${LOG_PREFIX}${e.message}`);

22
tsconfig.json Normal file
View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"outDir": "dist",
"target": "ES2017",
"module": "CommonJS",
"moduleResolution": "Node",
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
// "noImplicitAny": true, // enabled on strict mode
"noImplicitReturns": true,
// "noImplicitThis": true, // enabled on strict mode
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true
},
"files": ["src/index.ts"],
"include": ["src/**/*"]
}