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

fix: improve type for upload file v2 #1848

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Conversation

WilliamBergamin
Copy link
Contributor

Summary

This PR aims to fix #1846 by adding additional typing and related tests

Testing

  1. Pull this branch
  2. cd packages/web-api
  3. npm build
  4. In a project with the following app.ts
import { WebClient } from '@slack/web-api';

const client = new WebClient('mytoken');

(async () => {
  client.filesUploadV2({
    channel_id: 'C123',
    thread_ts: '173.029',
    content: 'test',
    filename: 'slack.json',
    title: 'test',
  });
})();
  1. with npm install ~/path/to/node-slack-sdk/packages/web-api the above should not create any typescript errors or warnings
  2. change channel_id -> channels, you should see the following warning when running the app
[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').

Requirements (place an x in each [ ])

@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` labels Jul 18, 2024
@WilliamBergamin WilliamBergamin self-assigned this Jul 18, 2024
@@ -144,6 +144,8 @@ export type FileUploadV2 = FileUpload & {
alt_text?: string;
/** @description Channel ID where the file will be shared. If not specified the file will be private. */
channel_id?: string;
/** @deprecated use channel_id instead */
Copy link
Contributor Author

@WilliamBergamin WilliamBergamin Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we could do anything else then deprecate this 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nailed it!

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Nicely done. Hopefully sorting through all the different combinations of types/interfaces wasn't too bad 🙏

And don't worry about the node 22 failures - I am looking into it. I think it's a new npm bug. As long as 18 and 20 pass, you are good! Merge away!

@@ -144,6 +144,8 @@ export type FileUploadV2 = FileUpload & {
alt_text?: string;
/** @description Channel ID where the file will be shared. If not specified the file will be private. */
channel_id?: string;
/** @deprecated use channel_id instead */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nailed it!

@WilliamBergamin WilliamBergamin merged commit a055e66 into main Jul 18, 2024
19 of 28 checks passed
@WilliamBergamin WilliamBergamin deleted the fix-upload-v2-types branch July 18, 2024 19:24
@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 this pull request may close these issues.

Using Typescript, filesUploadV2 requires deprecated 'channels' argument when 'thread_ts' is given
2 participants