upload_widget: Fix TypeScript noUncheckedIndexedAccess errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-05-30 10:08:00 -07:00
parent 6c0c19addb
commit 067a342b4e

View File

@@ -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(