From 9c52ed206561c1dc7732b03ffa527bafcef487f0 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Mon, 9 Sep 2024 12:44:15 -0700 Subject: [PATCH] more type fixes --- src/loaders.ts | 14 ++------------ src/wacz/waczloader.ts | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/loaders.ts b/src/loaders.ts index 9bbcc10..1d4fcde 100644 --- a/src/loaders.ts +++ b/src/loaders.ts @@ -566,7 +566,7 @@ export class WorkerLoader extends CollectionLoader { progressUpdate: any, ): Promise { // @ts-expect-error [TODO] - TS4111 - Property 'name' comes from an index signature, so it must be accessed with ['name']. - let name = data.name; + let name: string = data.name; let type = ""; // @ts-expect-error [TODO] - TS4111 - Property 'root' comes from an index signature, so it must be accessed with ['root']. @@ -758,17 +758,13 @@ Make sure this is a valid URL and you have access to this file.`, if (sourceExt === ".wacz") { if (config.onDemand) { - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument loader = new SingleWACZLoader(sourceLoader, config, name); // @ts-expect-error [TODO] - TS2345 - Argument of type 'Record' is not assignable to parameter of type 'Config'. - db = new MultiWACZ(config, sourceLoader, "wacz"); + db = new MultiWACZ(config as WACZCollConfig, sourceLoader, "wacz"); type = "wacz"; // can load on demand, but want a full import } else if (sourceLoader.canLoadOnDemand && file.newFullImport) { - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument loader = new SingleWACZFullImportLoader(sourceLoader, config, name); //use default db db = null; @@ -791,12 +787,8 @@ Make sure this is a valid URL and you have access to this file.`, !config.noCache && (contentLength < MAX_FULL_DOWNLOAD_SIZE || !config.onDemand) ) { - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument loader = new WARCLoader(stream, abort, name); } else { - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument loader = new CDXFromWARCLoader(stream, abort, name); type = "remotesource"; db = new RemoteSourceArchiveDB( @@ -809,8 +801,6 @@ Make sure this is a valid URL and you have access to this file.`, config.remotePrefix = // @ts-expect-error [TODO] - TS4111 - Property 'remotePrefix' comes from an index signature, so it must be accessed with ['remotePrefix']. data.remotePrefix || loadUrl.slice(0, loadUrl.lastIndexOf("/") + 1); - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument loader = new CDXLoader(stream, abort, name); type = "remoteprefix"; db = new RemotePrefixArchiveDB( diff --git a/src/wacz/waczloader.ts b/src/wacz/waczloader.ts index 4e504db..5c7a4f2 100644 --- a/src/wacz/waczloader.ts +++ b/src/wacz/waczloader.ts @@ -1,5 +1,5 @@ import { type BaseLoader } from "../blockloaders"; -import { type ArchiveLoader } from "../types"; +import { type CollConfig, type ArchiveLoader } from "../types"; import { MAX_FULL_DOWNLOAD_SIZE } from "../utils"; import { WARCLoader } from "../warcloader"; @@ -14,13 +14,14 @@ export class SingleWACZLoader implements ArchiveLoader { loadId: string | null = null; loadUrl: string; - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - constructor(loader: BaseLoader, config: Record, loadId = null) { + constructor( + loader: BaseLoader, + config: CollConfig, + loadId: string | null = null, + ) { this.loader = loader; this.loadId = loadId; - // @ts-expect-error [TODO] - TS4111 - Property 'loadUrl' comes from an index signature, so it must be accessed with ['loadUrl']. - this.loadUrl = config.loadUrl; + this.loadUrl = config.loadUrl!; } // [TODO] @@ -53,13 +54,13 @@ export class SingleWACZLoader implements ArchiveLoader { export class SingleWACZFullImportLoader implements ArchiveLoader { loader: BaseLoader; loadId: string | null = null; - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - config: Record; + config: CollConfig; - // [TODO] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - constructor(loader: BaseLoader, config: Record, loadId = null) { + constructor( + loader: BaseLoader, + config: CollConfig, + loadId: string | null = null, + ) { this.config = config; this.loadId = loadId;