From 20d9a8e00906afee139a8dedf7df884a09ec73f1 Mon Sep 17 00:00:00 2001 From: kenkoooo Date: Tue, 23 Sep 2025 07:26:44 +0900 Subject: [PATCH] fix: align files.uploadV2 return type --- docs/english/reference/web-api/classes/Methods.md | 5 ++++- docs/english/reference/web-api/classes/WebClient.md | 5 ++++- packages/web-api/src/methods.ts | 9 +++++++-- packages/web-api/test/types/methods/files.test-d.ts | 5 +++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/english/reference/web-api/classes/Methods.md b/docs/english/reference/web-api/classes/Methods.md index 8373714e8..53dd4f7ee 100644 --- a/docs/english/reference/web-api/classes/Methods.md +++ b/docs/english/reference/web-api/classes/Methods.md @@ -3063,7 +3063,10 @@ Use `uploadV2` instead. See [our post on retiring \`files.upload\`](https://docs #### uploadV2 ```ts -uploadV2: MethodWithRequiredArgument; +uploadV2: MethodWithRequiredArgument< + FilesUploadV2Arguments, + WebAPICallResult & { files: FilesCompleteUploadExternalResponse[] } +>; ``` ##### Description diff --git a/docs/english/reference/web-api/classes/WebClient.md b/docs/english/reference/web-api/classes/WebClient.md index 5f93cabee..6d102a16e 100644 --- a/docs/english/reference/web-api/classes/WebClient.md +++ b/docs/english/reference/web-api/classes/WebClient.md @@ -3151,7 +3151,10 @@ Use `uploadV2` instead. See [our post on retiring \`files.upload\`](https://docs #### uploadV2 ```ts -uploadV2: MethodWithRequiredArgument; +uploadV2: MethodWithRequiredArgument< + FilesUploadV2Arguments, + WebAPICallResult & { files: FilesCompleteUploadExternalResponse[] } +>; ``` ##### Description diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index ce6ad3e9b..852eb1f36 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -573,7 +573,9 @@ export abstract class Methods extends EventEmitter { } public abstract apiCall(method: string, options?: Record): Promise; - public abstract filesUploadV2(options: FilesUploadV2Arguments): Promise; + public abstract filesUploadV2( + options: FilesUploadV2Arguments, + ): Promise; public readonly admin = { analytics: { @@ -1928,7 +1930,10 @@ export abstract class Methods extends EventEmitter { * as multiple file uploads property. * @see {@link https://docs.slack.dev/tools/node-slack-sdk/web-api/#upload-a-file `@slack/web-api` Upload a file documentation}. */ - uploadV2: bindFilesUploadV2(this), + uploadV2: bindFilesUploadV2< + FilesUploadV2Arguments, + WebAPICallResult & { files: FilesCompleteUploadExternalResponse[] } + >(this), comments: { /** * @description Deletes an existing comment on a file. 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 60b8e873b..aff821bf3 100644 --- a/packages/web-api/test/types/methods/files.test-d.ts +++ b/packages/web-api/test/types/methods/files.test-d.ts @@ -1,5 +1,7 @@ import { expectAssignable, expectError } from 'tsd'; import { WebClient } from '../../../src/WebClient'; +import type { WebAPICallResult } from '../../../src/WebClient'; +import type { FilesCompleteUploadExternalResponse } from '../../../src/types/response/FilesCompleteUploadExternalResponse'; const web = new WebClient('TOKEN'); @@ -177,6 +179,9 @@ expectAssignable>([ content: 'text', }, ]); +expectAssignable>( + web.files.uploadV2({ content: 'text' }), +); // files.comments.delete // -- sad path