From 067a342b4e0fa880fb1bcea5cc7359988ff0e46b Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 30 May 2024 10:08:00 -0700 Subject: [PATCH] upload_widget: Fix TypeScript noUncheckedIndexedAccess errors. Signed-off-by: Anders Kaseorg --- web/src/upload_widget.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/upload_widget.ts b/web/src/upload_widget.ts index 94406741dc..c795c45731 100644 --- a/web/src/upload_widget.ts +++ b/web/src/upload_widget.ts @@ -79,9 +79,9 @@ export function build_widget( get_file_input().attr("accept", supported_types.toString()); get_file_input().on("change", (e) => { - if (e.target.files?.length === 0) { + if (e.target.files?.[0] === undefined) { $input_error.hide(); - } else if (e.target.files?.length === 1) { + } else if (e.target.files.length === 1) { const file = e.target.files[0]; if (file.size > max_file_upload_size * 1024 * 1024) { $input_error.text( @@ -167,9 +167,9 @@ export function build_direct_upload_widget( get_file_input().attr("accept", supported_types.toString()); get_file_input().on("change", (e) => { - if (e.target.files?.length === 0) { + if (e.target.files?.[0] === undefined) { $input_error.hide(); - } else if (e.target.files?.length === 1) { + } else if (e.target.files.length === 1) { const file = e.target.files[0]; if (file.size > max_file_upload_size * 1024 * 1024) { $input_error.text(