Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Missing TypeScript response type for files.uploadV2

Aperta Adatta ai principianti
#2,459 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dajiaohuang ci sta già lavorando.

Dal 25/9/2026.

  • #2751 di @dajiaohuang — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
api

Direzione di ricerca

Inizia in methods.d.ts confrontando la dichiarazione di files.uploadV2 con la tipizzazione esistente di files.upload e FilesUploadResponse. Definisci e collega la forma specifica della risposta descritta nell’issue, quindi verifica che l’accesso a result.files e agli id dei file annidati venga verificato dal type checker senza il workaround.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
3.4k
Fork
691
Merge medio
1g 2h
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di slackapi/node-slack-sdk

Tutte le issue di slackapi/node-slack-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.