Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upload_widget: Fix TypeScript noUncheckedIndexedAccess errors.

Anders Kaseorg067a342b4e0f
diff --git a/web/src/upload_widget.ts b/web/src/upload_widget.ts
index 94406741dc3..c795c45731d 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(