Fix type annotations and module imports

Added explicit type annotations to array mapping functions for better type safety. Updated incorrect TypeScript import extensions from .ts to .js for compatibility. Ensured default values for optional parameters and improved code clarity in API routers.
This commit is contained in:
CanbiZ
2025-11-28 12:29:15 +01:00
parent 1945b14694
commit 7547dff67d
5 changed files with 8 additions and 8 deletions

View File

@@ -47,7 +47,7 @@ export function ServerStoragesModal({
const credentialsMap = new Map<string, boolean>();
if (allCredentials?.success) {
allCredentials.credentials.forEach((c) => {
allCredentials.credentials.forEach((c: { storage_name: string }) => {
credentialsMap.set(String(c.storage_name), true);
});
}

View File

@@ -56,7 +56,7 @@ export const pbsCredentialsRouter = createTRPCRouter({
return {
success: true,
credentials: credentials.map(c => ({
credentials: credentials.map((c: { id: number; server_id: number; storage_name: string; pbs_ip: string; pbs_datastore: string; pbs_fingerprint: string; pbs_password: string }) => ({
id: c.id,
server_id: c.server_id,
storage_name: c.storage_name,
@@ -109,7 +109,7 @@ export const pbsCredentialsRouter = createTRPCRouter({
storage_name: input.storageName,
pbs_ip: input.pbs_ip,
pbs_datastore: input.pbs_datastore,
pbs_password: passwordToSave,
pbs_password: passwordToSave ?? '',
pbs_fingerprint: input.pbs_fingerprint,
});

View File

@@ -101,7 +101,7 @@ export const scriptsRouter = createTRPCRouter({
getAllScripts: publicProcedure
.query(async () => {
try {
const scripts = await githubJsonService.getAllScripts();
const scripts = await localScriptsService.getAllScripts();
return { success: true, scripts };
} catch (error) {
return {
@@ -178,7 +178,7 @@ export const scriptsRouter = createTRPCRouter({
const scripts = await localScriptsService.getAllScripts();
// Create a set of enabled repository URLs for fast lookup
const enabledRepoUrls = new Set(enabledRepos.map(repo => repo.url));
const enabledRepoUrls = new Set(enabledRepos.map((repo: { url: string }) => repo.url));
// Create category ID to name mapping
const categoryMap: Record<number, string> = {};

View File

@@ -3,7 +3,7 @@ import { writeFile, mkdir, readdir, readFile } from 'fs/promises';
import { join } from 'path';
import { env } from '../../env.js';
import type { Script, ScriptCard, GitHubFile } from '../../types/script';
import { repositoryService } from './repositoryService.ts';
import { repositoryService } from './repositoryService.js';
export class GitHubJsonService {
private branch: string | null = null;

View File

@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument, @typescript-eslint/prefer-regexp-exec */
import { prisma } from '../db.ts';
import { prisma } from '../db.js';
export class RepositoryService {
/**
@@ -18,7 +18,7 @@ export class RepositoryService {
}
});
const existingUrls = new Set(existingRepos.map(r => r.url));
const existingUrls = new Set(existingRepos.map((r: { url: string }) => r.url));
// Create main repo if it doesn't exist
if (!existingUrls.has(mainRepoUrl)) {