Fix strict TypeScript checks for server

This commit is contained in:
nav
2026-04-09 04:38:07 +00:00
parent 2972c4750e
commit 31f41cb49b
7 changed files with 52 additions and 14 deletions

View File

@@ -35,7 +35,7 @@ function normalizeOptionalString(value: unknown): string | undefined {
}
function isValidPort(value: unknown): value is number {
return Number.isInteger(value) && value >= 1 && value <= 65535;
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 65535;
}
function isValidWsUrl(value: string): boolean {
@@ -67,18 +67,18 @@ export function validateYonexusServerConfig(raw: unknown): YonexusServerConfig {
issues.push("followerIdentifiers must not contain duplicates");
}
const notifyBotToken = source.notifyBotToken;
if (!isNonEmptyString(notifyBotToken)) {
const rawNotifyBotToken = source.notifyBotToken;
if (!isNonEmptyString(rawNotifyBotToken)) {
issues.push("notifyBotToken is required");
}
const adminUserId = source.adminUserId;
if (!isNonEmptyString(adminUserId)) {
const rawAdminUserId = source.adminUserId;
if (!isNonEmptyString(rawAdminUserId)) {
issues.push("adminUserId is required");
}
const listenPort = source.listenPort;
if (!isValidPort(listenPort)) {
const rawListenPort = source.listenPort;
if (!isValidPort(rawListenPort)) {
issues.push("listenPort must be an integer between 1 and 65535");
}
@@ -93,6 +93,10 @@ export function validateYonexusServerConfig(raw: unknown): YonexusServerConfig {
throw new YonexusServerConfigError(issues);
}
const notifyBotToken = rawNotifyBotToken as string;
const adminUserId = rawAdminUserId as string;
const listenPort = rawListenPort as number;
return {
followerIdentifiers,
notifyBotToken: notifyBotToken.trim(),