From a055e661c6c1f80386d81d5ea971df0e7e7bc2a0 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Thu, 18 Jul 2024 19:24:27 +0000 Subject: [PATCH] fix: improve type for upload file v2 (#1848) --- packages/web-api/src/types/request/files.ts | 4 +++- packages/web-api/test/types/methods/files.test-d.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/web-api/src/types/request/files.ts b/packages/web-api/src/types/request/files.ts index 8ad24f371..b4e7fa68e 100644 --- a/packages/web-api/src/types/request/files.ts +++ b/packages/web-api/src/types/request/files.ts @@ -128,7 +128,7 @@ export interface FileUploadBinaryContents { // File upload contents can be provided using either `content` or `file` arguments - and one of these is required. type FileUploadContents = FileUploadStringContents | FileUploadBinaryContents; -type FileUpload = FileUploadContents & FileDestinationArgumentChannels & FileType & { +type FileUpload = FileUploadContents & (FileDestinationArgumentChannels | FileDestinationArgument) & FileType & { /** @description Name of the file. */ filename?: string; /** @description The message text introducing the file in specified channel(s). */ @@ -144,6 +144,8 @@ export type FileUploadV2 = FileUpload & { alt_text?: string; /** @description Channel ID where the file will be shared. If not specified the file will be private. */ channel_id?: string; + /** @deprecated use channel_id instead */ + channels?: string; /** @description Syntax type of the snippet being uploaded. E.g. `python`. */ snippet_type?: string; }; diff --git a/packages/web-api/test/types/methods/files.test-d.ts b/packages/web-api/test/types/methods/files.test-d.ts index 1e6675663..60e69d8ca 100644 --- a/packages/web-api/test/types/methods/files.test-d.ts +++ b/packages/web-api/test/types/methods/files.test-d.ts @@ -123,11 +123,20 @@ expectAssignable>([{ channels: 'C1234', // optionally share to one or more channels content: 'text', }]); +expectAssignable>([{ + channel_id: 'C1234', // optionally share to one or more channels + content: 'text', +}]); expectAssignable>([{ channels: 'C1234', thread_ts: '12345.67', // or even to a specific thread content: 'text', }]); +expectAssignable>([{ + channel_id: 'C1234', + thread_ts: '12345.67', // or even to a specific thread + content: 'text', +}]); // files.comments.delete // -- sad path