From 20453aab4391d1bdf782f147fc83323bb009c986 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Mon, 1 Dec 2025 16:03:27 +1300 Subject: [PATCH] res.json type fixes --- scripts/setup.js | 8 ++------ src/d2m/actions/register-pk-user.js | 1 + src/matrix/mreq.js | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/setup.js b/scripts/setup.js index ecef03d..07ded56 100644 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -50,11 +50,6 @@ let {reg, getTemplateRegistration, writeRegistration, readRegistration, checkReg const {setupEmojis} = require("../src/m2d/actions/setup-emojis") -function die(message) { - console.error(message) - process.exit(1) -} - async function suggestWellKnown(serverUrlPrompt, url, otherwise) { try { var json = await fetch(`${url}/.well-known/matrix/client`).then(res => res.json()) @@ -80,6 +75,7 @@ async function validateHomeserverOrigin(serverUrlPrompt, url) { return e.message } try { + /** @type {any} */ var json = await res.json() if (!Array.isArray(json?.versions) || !json.versions.includes("v1.11")) { return `OOYE needs Matrix version v1.11, but ${url} doesn't support this` @@ -130,7 +126,7 @@ function defineEchoHandler() { initial: "6693" }) portResponse.socket = +portResponse.socket || portResponse.socket // convert to number if numeric - + const app = createApp() app.use(defineEchoHandler()) const server = createServer(toNodeListener(app)) diff --git a/src/d2m/actions/register-pk-user.js b/src/d2m/actions/register-pk-user.js index e17f061..e73fa44 100644 --- a/src/d2m/actions/register-pk-user.js +++ b/src/d2m/actions/register-pk-user.js @@ -22,6 +22,7 @@ async function fetchMessage(messageID) { throw new Error(`Failed to connect to PK API: ${networkError.toString()}`) } if (!res.ok) throw new Error(`PK API returned an error: ${await res.text()}`) + /** @type {any} */ const root = await res.json() if (!root.member) throw new Error(`PK API didn't return member data: ${JSON.stringify(root)}`) return root diff --git a/src/matrix/mreq.js b/src/matrix/mreq.js index 384950e..bb35975 100644 --- a/src/matrix/mreq.js +++ b/src/matrix/mreq.js @@ -72,6 +72,7 @@ async function mreq(method, url, bodyIn, extra = {}) { }, extra) const res = await fetch(baseUrl + url, opts) + /** @type {any} */ const root = await res.json() if (!res.ok || root.errcode) {