Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Typescript, filesUploadV2 requires deprecated 'channels' argument when 'thread_ts' is given #1846

Closed
1 of 7 tasks
rcfox opened this issue Jul 18, 2024 · 2 comments · Fixed by #1848
Closed
1 of 7 tasks
Labels
area:typescript issues that specifically impact using the package from typescript projects bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:web-api applies to `@slack/web-api` semver:patch

Comments

@rcfox
Copy link

rcfox commented Jul 18, 2024

Packages:

Select all that apply:

  • @slack/web-api
  • @slack/rtm-api
  • @slack/webhooks
  • @slack/oauth
  • @slack/socket-mode
  • @slack/types
  • I don't know

Reproducible in:

The Slack SDK version

"slack/web-api": "^7.3.1",

Node.js runtime version

v21.6.2

Typescript version

"typescript": "5.4.5",

Steps to reproduce:

With the following code:

    const token = '...';
    const channelId = '...';

    const slack = new WebClient(token);

    const response = await slack.chat.postMessage({
      text: `hello`,
      channel: channelId,
    });

    await slack.filesUploadV2({
      channel_id: channelId,
      thread_ts: response.ts,
      content: 'test',
      filename: 'test.txt',
      title: 'test',
    });

I get the following Typescript compile error:

Property 'channels' is missing in type '{ channel_id: string; thread_ts: string; content: string; filename: string; title: string; }' but required in type 'FileThreadDestinationArgumentChannels'.

However, if I include the channels field, I get a warning at runtime:

[WARN] web-api:WebClient:0 Although the 'channels' parameter is still supported for smoother migration from legacy files.upload, we recommend using the new channel_id parameter with a single str value instead (e.g. 'C12345').

If the thread_ts argument is not included, then channels is not required.

@WilliamBergamin WilliamBergamin added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch area:typescript issues that specifically impact using the package from typescript projects pkg:web-api applies to `@slack/web-api` and removed untriaged labels Jul 18, 2024
@WilliamBergamin
Copy link
Contributor

WilliamBergamin commented Jul 18, 2024

Hi @rcfox thanks for bringing this up 💯

I was able to reproduce this behavior with the following code

import { WebClient } from '@slack/web-api';

const client = new WebClient('mytoken');

(async () => {
  client.filesUploadV2({
    channels: 'C123',
    thread_ts: '1723.09',
    content: 'test',
    filename: 'slack.json',
    title: 'test',
  });
})();

@rcfox
Copy link
Author

rcfox commented Jul 18, 2024

Amazing response time. Thanks!

@filmaj filmaj added this to the [email protected] milestone Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typescript issues that specifically impact using the package from typescript projects bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented pkg:web-api applies to `@slack/web-api` semver:patch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants