From 797e5b63e73c89c4605867e2d02646d38122674a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 23 Jan 2022 20:50:48 -0800 Subject: [PATCH] tsc --- server/routes/index.ts | 15 +++++---------- server/services/websockets.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/server/routes/index.ts b/server/routes/index.ts index f37805553..8f89beac4 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -1,7 +1,7 @@ import fs from "fs"; import path from "path"; import util from "util"; -import Koa from "koa"; +import Koa, { Context, Next } from "koa"; import Router from "koa-router"; import send from "koa-send"; import serve from "koa-static"; @@ -22,8 +22,7 @@ const koa = new Koa(); const router = new Router(); const readFile = util.promisify(fs.readFile); -// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. -const readIndexFile = async (ctx) => { +const readIndexFile = async (ctx: Context): Promise => { if (isProduction) { return readFile(path.join(__dirname, "../../app/index.html")); } @@ -37,8 +36,7 @@ const readIndexFile = async (ctx) => { return new Promise((resolve, reject) => { middleware.fileSystem.readFile( `${ctx.webpackConfig.output.path}/index.html`, - // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'err' implicitly has an 'any' type. - (err, result) => { + (err: Error, result: Buffer) => { if (err) { return reject(err); } @@ -49,8 +47,7 @@ const readIndexFile = async (ctx) => { }); }; -// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. -const renderApp = async (ctx, next, title = "Outline") => { +const renderApp = async (ctx: Context, next: Next, title = "Outline") => { if (ctx.request.path === "/realtime/") { return next(); } @@ -59,7 +56,6 @@ const renderApp = async (ctx, next, title = "Outline") => { const environment = ` window.env = ${JSON.stringify(presentEnv(env))}; `; - // @ts-expect-error ts-migrate(2571) FIXME: Object is of type 'unknown'. ctx.body = page .toString() .replace(/\/\/inject-env\/\//g, environment) @@ -68,8 +64,7 @@ const renderApp = async (ctx, next, title = "Outline") => { .replace(/\/\/inject-slack-app-id\/\//g, process.env.SLACK_APP_ID || ""); }; -// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. -const renderShare = async (ctx, next) => { +const renderShare = async (ctx: Context, next: Next) => { const { shareId } = ctx.params; // Find the share record if publicly published so that the document title // can be be returned in the server-rendered HTML. This allows it to appear in diff --git a/server/services/websockets.ts b/server/services/websockets.ts index 5d45a937b..b3069bc2d 100644 --- a/server/services/websockets.ts +++ b/server/services/websockets.ts @@ -29,8 +29,12 @@ export default function init(app: Koa, server: http.Server) { const listeners = server.listeners("upgrade"); const ioHandleUpgrade = listeners.pop(); - // @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Function | undefined' is not ass... Remove this comment to see the full error message - server.removeListener("upgrade", ioHandleUpgrade); + if (ioHandleUpgrade) { + server.removeListener( + "upgrade", + ioHandleUpgrade as (...args: any[]) => void + ); + } server.on("upgrade", function (req, socket, head) { if (req.url && req.url.indexOf(path) > -1) {