From 2147bc9e63d2ee90c53a50a7e67160e0605a3613 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Wed, 4 Sep 2024 15:39:49 +0000
Subject: [PATCH 1/3] chore(deps-dev): bump typescript in /packages/web-api

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.3.3 to 5.5.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.3.3...v5.5.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
---
 packages/web-api/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/web-api/package.json b/packages/web-api/package.json
index fcfb3b8f8..07e9cc8af 100644
--- a/packages/web-api/package.json
+++ b/packages/web-api/package.json
@@ -85,7 +85,7 @@
     "source-map-support": "^0.5.21",
     "ts-node": "^10",
     "tsd": "^0.31.1",
-    "typescript": "5.3.3"
+    "typescript": "5.5.4"
   },
   "tsd": {
     "directory": "test/types"

From 462d43995b6975d4d00d8f99c00d31f6b8a3ead1 Mon Sep 17 00:00:00 2001
From: William Bergamin <wbergamin@slack-corp.com>
Date: Wed, 4 Sep 2024 13:33:41 -0400
Subject: [PATCH 2/3] Fix typescript error

---
 packages/web-api/src/file-upload.ts         | 18 ++++++++++++------
 packages/web-api/src/types/request/files.ts |  2 +-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/packages/web-api/src/file-upload.ts b/packages/web-api/src/file-upload.ts
index 78e26f3fd..02c99f54d 100644
--- a/packages/web-api/src/file-upload.ts
+++ b/packages/web-api/src/file-upload.ts
@@ -227,13 +227,19 @@ Record<string, FilesCompleteUploadExternalArguments> {
     if (file_id) {
       const compareString = `:::${channel_id}:::${thread_ts}:::${initial_comment}`;
       if (!Object.prototype.hasOwnProperty.call(toComplete, compareString)) {
-        toComplete[compareString] = {
-          files: [{ id: file_id, title }],
-          channel_id,
-          initial_comment,
-        };
         if (thread_ts) {
-          toComplete[compareString].thread_ts = upload.thread_ts;
+          toComplete[compareString] = {
+            files: [{ id: file_id, title }],
+            channel_id,
+            initial_comment,
+            thread_ts
+          };
+        }else{
+          toComplete[compareString] = {
+            files: [{ id: file_id, title }],
+            channel_id,
+            initial_comment,
+          };
         }
         if ('token' in upload) {
           toComplete[compareString].token = upload.token;
diff --git a/packages/web-api/src/types/request/files.ts b/packages/web-api/src/types/request/files.ts
index b4e7fa68e..8abf8d592 100644
--- a/packages/web-api/src/types/request/files.ts
+++ b/packages/web-api/src/types/request/files.ts
@@ -44,7 +44,7 @@ interface FileChannelDestinationArgument {
 }
 interface FileThreadDestinationArgument {
   /** @description Channel ID where the file will be shared as a thread reply. */
-  channel_id: string;
+  channel_id?: string;
   /** @description Provide another message's `ts` value to upload this file as a reply. */
   thread_ts: string;
 }

From 8f66dbf9e2153cc4b086b5a4a87a03361e198bac Mon Sep 17 00:00:00 2001
From: William Bergamin <wbergamin@slack-corp.com>
Date: Wed, 4 Sep 2024 13:42:07 -0400
Subject: [PATCH 3/3] Needs channel id and thread ts

---
 packages/web-api/src/file-upload.ts         | 6 +++---
 packages/web-api/src/types/request/files.ts | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/packages/web-api/src/file-upload.ts b/packages/web-api/src/file-upload.ts
index 02c99f54d..0a7083aaa 100644
--- a/packages/web-api/src/file-upload.ts
+++ b/packages/web-api/src/file-upload.ts
@@ -227,14 +227,14 @@ Record<string, FilesCompleteUploadExternalArguments> {
     if (file_id) {
       const compareString = `:::${channel_id}:::${thread_ts}:::${initial_comment}`;
       if (!Object.prototype.hasOwnProperty.call(toComplete, compareString)) {
-        if (thread_ts) {
+        if (channel_id && thread_ts) {
           toComplete[compareString] = {
             files: [{ id: file_id, title }],
             channel_id,
             initial_comment,
-            thread_ts
+            thread_ts,
           };
-        }else{
+        } else {
           toComplete[compareString] = {
             files: [{ id: file_id, title }],
             channel_id,
diff --git a/packages/web-api/src/types/request/files.ts b/packages/web-api/src/types/request/files.ts
index 8abf8d592..b4e7fa68e 100644
--- a/packages/web-api/src/types/request/files.ts
+++ b/packages/web-api/src/types/request/files.ts
@@ -44,7 +44,7 @@ interface FileChannelDestinationArgument {
 }
 interface FileThreadDestinationArgument {
   /** @description Channel ID where the file will be shared as a thread reply. */
-  channel_id?: string;
+  channel_id: string;
   /** @description Provide another message's `ts` value to upload this file as a reply. */
   thread_ts: string;
 }