upload: 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 e134ad1363
commit 6c0c19addb
2 changed files with 3 additions and 3 deletions

View File

@ -534,7 +534,7 @@ export function initialize(): void {
if (compose_state.composing()) {
// Compose box is open; drop there.
upload_files(compose_upload_object, compose_config, files);
} else if ($last_drag_drop_edit_container.length !== 0) {
} else if ($last_drag_drop_edit_container[0] !== undefined) {
// A message edit box is open; drop there.
const row_id = rows.get_message_id($last_drag_drop_edit_container[0]);
const $drag_drop_container = edit_config(row_id).drag_drop_container();

View File

@ -754,7 +754,7 @@ test("main_file_drop_edit_mode", ({override, override_rewire}) => {
dropped_row_id = config.row;
upload_files_called = true;
});
$(".message_edit_form form").last = () => ({length: 1});
$(".message_edit_form form").last = () => ({length: 1, [0]: "stub"});
override(rows, "get_message_id", () => 40);
// Edit box which registered the event handler no longer exists.
@ -776,7 +776,7 @@ test("main_file_drop_edit_mode", ({override, override_rewire}) => {
override(rows, "get_message_id", () => 40);
// Edit box open
$(".message_edit_form form").last = () => ({length: 1});
$(".message_edit_form form").last = () => ({length: 1, [0]: "stub"});
drop_handler(drop_event);
assert.equal(upload_files_called, true);
assert.equal(dropped_row_id, 40);