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
- 派生
- 691
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 19
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
slackapi/node-slack-sdk 的其他 Issue
-
ThreadBroadcastMessageEvent is missing `bot_id`可能已有人在做 @sean0407 于 10 天前认领。 未关闭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 于 23 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
slackapi/node-slack-sdk#2753 ·
维护者通常 1 天内回复
-
Support assistant.search.* APIs可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭auto-triage-skip enhancement pkg:web-api
难度 2/5 1-3 小时 新手友好度 68/100
slackapi/node-slack-sdk#2607 · 2 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
`SlackListsItem FieldMessage.message` type does not match API response shape可能已有人在做 @AjTheSpidey 于 161 天前认领。 未关闭area:typescript auto-triage-skip bug pkg:web-api
难度 2/5 1-3 小时 新手友好度 82/100
slackapi/node-slack-sdk#2598 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 75/100
slackapi/node-slack-sdk#2791 ·
维护者通常 1 天内回复
查看 slackapi/node-slack-sdk 的全部 Issue
相似的 Issue
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefix可能已有人在做 @ItsDeadlyProgrammer 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
appsmithorg/appsmith#42471 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
ehmpathy/rhachet-roles-bhrain#705 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
Status: Triage
难度 2/5 1-3 小时 新手友好度 76/100
mermaid-js/mermaid#8546 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
braintrustdata/braintrust-sdk-javascript#2659 ·
维护者通常 1 天内回复