Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Missing TypeScript response type for files.uploadV2

オープン 初心者向け
#2,459 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@dajiaohuang がすでに取り組んでいます。

2026年9月25日 から。

  • #2751 @dajiaohuang による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
66/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
typescript
領域
api

調査の方向性

methods.d.ts で、files.uploadV2 の宣言を既存の files.upload および FilesUploadResponse の型定義と比較することから始めます。Issue で説明されている具体的なレスポンスの形状を定義して関連付け、その後、workaround なしで result.files とネストされたファイル ID へのアクセスが型チェックを通ることを確認します。

索引モデルが issue の本文から書いたものです。

説明

area:typescript auto-triage-skip bug pkg:web-api

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-api version: 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

slackapi/node-slack-sdk のほかの issue

slackapi/node-slack-sdk の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。