Missing TypeScript response type for files.uploadV2
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 66/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- api
調査の方向性
methods.d.ts で、files.uploadV2 の宣言を既存の files.upload および FilesUploadResponse の型定義と比較することから始めます。Issue で説明されている具体的なレスポンスの形状を定義して関連付け、その後、workaround なしで result.files とネストされたファイル ID へのアクセスが型チェックを通ることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Description
The files.uploadV2 method returns WebAPICallResult instead of a specific response type like other file methods have. This causes TypeScript errors when accessing the files property from the response.
Current behavior
// In methods.d.ts
uploadV2: MethodWithRequiredArgument<FilesUploadV2Arguments, WebAPICallResult>;
// Usage causes TS error
const result = await client.files.uploadV2({ file: buffer, filename });
const fileId = result.files[0].files[0].id;
// Error: Property 'files' does not exist on type 'WebAPICallResult'. (ts 2339)
Expected behavior
A specific response type should be defined, similar to other methods:
// Expected in methods.d.ts
uploadV2: MethodWithRequiredArgument<FilesUploadV2Arguments, FilesUploadV2Response>;
Actual API response structure
The actual response from files.uploadV2 has this structure:
{
"ok": true,
"files": [
{
"ok": true,
"files": [
{
"id": "F0A68QU0H08",
"created": 1766578264,
"timestamp": 1766578264,
"name": "filename.jpg",
"title": "filename.jpg",
"mimetype": "",
"filetype": "",
"user": "U0A57PBUCR1",
"size": 266967,
"mode": "hosted",
"is_external": false,
"is_public": false,
"url_private": "https://files.slack.com/...",
"url_private_download": "https://files.slack.com/.../download/...",
"permalink": "https://....slack.com/files/...",
"permalink_public": "https://slack-files.com/...",
"file_access": "visible"
}
],
"response_metadata": {
"scopes": ["files:write", "..."],
"acceptedScopes": ["files:write"]
}
}
]
}
Suggested type definition
export interface FilesUploadV2Response extends WebAPICallResult {
files: Array<{
ok: boolean;
files: Array<{
id: string;
created: number;
timestamp: number;
name: string;
title: string;
mimetype: string;
filetype: string;
user: string;
user_team: string;
size: number;
mode: string;
is_external: boolean;
is_public: boolean;
url_private: string;
url_private_download: string;
permalink: string;
permalink_public: string;
file_access: string;
// ... other optional fields
}>;
response_metadata?: {
scopes: string[];
acceptedScopes: string[];
};
}>;
}
Workaround
Currently using inline type cast:
const result =
/** @type {{ ok: boolean, files: Array<{ ok: boolean, files: Array<{ id: string }> }> }} */
(await client.files.uploadV2({ file: buffer, filename }));
Environment
@slack/web-apiversion: 7.13.0- Node.js version: 22.x
- TypeScript version: 5.x (via tsserver/JSDoc)
Related
The deprecated files.upload method has proper typing with FilesUploadResponse, but its replacement uploadV2 uses the generic WebAPICallResult.
Packages:
Select all that apply:
-
@slack/web-api -
@slack/rtm-api -
@slack/webhooks -
@slack/oauth -
@slack/socket-mode -
@slack/types - I don't know
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
- 主要言語
- TypeScript
- スター
- 3.4k
- フォーク
- 688
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
slackapi/node-slack-sdk のほかの issue
-
ThreadBroadcastMessageEvent is missing `bot_id`対応中かも @sean0407 が 7 日前に担当しました。 オープンuntriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
slackapi/node-slack-sdk#2766 ·
メンテナーはふだん 1 日以内に返信
-
SocketModeClient crashes on Events API payloads without an inner event対応中かも @kyungyeon-byun-imweb-me が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
slackapi/node-slack-sdk#2753 ·
メンテナーはふだん 1 日以内に返信
-
Support assistant.search.* APIs対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンauto-triage-skip enhancement pkg:web-api
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
slackapi/node-slack-sdk#2607 · コメント 2 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
`SlackListsItem FieldMessage.message` type does not match API response shape対応中かも @AjTheSpidey が 158 日前に担当しました。 オープンarea:typescript auto-triage-skip bug pkg:web-api
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
slackapi/node-slack-sdk#2598 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
untriaged
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
slackapi/node-slack-sdk#2773 ·
メンテナーはふだん 1 日以内に返信
slackapi/node-slack-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
mobile-next/mobile-mcp#526 ·
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 1/5 1時間未満 初心者へのやさしさ 73/100
redhat-developer/rhdh-plugin-export-overlays#4470 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信