From 0dc20c2949199185182c16569313660657dcb636 Mon Sep 17 00:00:00 2001 From: Nathan Stitt Date: Wed, 3 Dec 2025 16:44:13 -0600 Subject: [PATCH] Fix type warnings typescript in management app was throwing: Property 'getData' does not exist on type 'DirectoryEntry'. the way types were setup in zip.js, the entry is a union type and only typed as a DirectoryEntry if it had a .directory property, and as FileEntry when .file was present. Checking the properties allows typescript to infer types as it should --- job-results/reader.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/job-results/reader.ts b/job-results/reader.ts index 070b8b5..bab57dc 100644 --- a/job-results/reader.ts +++ b/job-results/reader.ts @@ -1,4 +1,4 @@ -import { BlobReader, BlobWriter, Entry, TextWriter, ZipReader } from '@zip.js/zip.js' +import { BlobReader, BlobWriter, FileEntry as ZipFileEntry, TextWriter, ZipReader } from '@zip.js/zip.js' import type { ResultsFile, ResultsManifest, FileEntry } from './types' import { privateKeyFromBuffer } from '../util' import logger from '../lib/logger' @@ -40,7 +40,7 @@ export class ResultsReader { const entries = await this.zipReader.getEntries() for (const entry of entries) { - if (entry.getData && entry.filename == 'manifest.json') { + if (!entry.directory && entry.filename == 'manifest.json') { const manifestText = await entry.getData(new TextWriter()) this.manifest = JSON.parse(manifestText) as ResultsManifest } @@ -57,18 +57,14 @@ export class ResultsReader { const entries = await this.zipReader.getEntries() for (const entry of entries) { const file = this.manifest.files[entry.filename] - if (entry.getData && file) { + if (!entry.directory && file) { const contents = await this.readFile(file, entry) yield { ...file, contents } } } } - private async readFile(fileEntry: ResultsFile, entry: Entry): Promise { - if (!entry.getData) { - throw new Error('Entry does not have data') - } - + private async readFile(fileEntry: ResultsFile, entry: ZipFileEntry): Promise { logger.info(`Reading file ${entry.filename}`) const encryptedData = await entry.getData(new BlobWriter())