From 9ff29cd3911c1a46a834b1603015a321a6ee1a06 Mon Sep 17 00:00:00 2001 From: Beeno Tung Date: Tue, 28 May 2024 22:49:56 +0800 Subject: [PATCH] fix tsc error, resolve ts-ignore with type-safe version code (#339) * patch: fix tsc error * chore: resolve ts-ignore with type-safe version code --- frontend/src/utils/web-file-operations.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/utils/web-file-operations.ts b/frontend/src/utils/web-file-operations.ts index 1d6f224..532683d 100644 --- a/frontend/src/utils/web-file-operations.ts +++ b/frontend/src/utils/web-file-operations.ts @@ -2,7 +2,7 @@ import { getDocument, GlobalWorkerOptions, PDFDocumentProxy } from 'pdfjs-dist'; import { TextItem } from 'pdfjs-dist/types/src/display/api'; export function webOpenOpenFileDialog(filterPattern: string, fnStartLoading: Function | undefined): Promise<{ - blob: Blob, + blob: File, content?: string }> { return new Promise((resolve, reject) => { @@ -16,8 +16,8 @@ export function webOpenOpenFileDialog(filterPattern: string, fnStartLoading: Fun .replaceAll(';', ','); input.onchange = async e => { - // @ts-ignore - const file: Blob = e.target?.files[0]; + const file = (e.target as HTMLInputElement).files?.[0]; + if (!file) return if (fnStartLoading && typeof fnStartLoading === 'function') fnStartLoading(); if (!GlobalWorkerOptions.workerSrc && file.type === 'application/pdf')