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

web-api: Consider removing need to provide empty object as argument to zero-argument methods #1769

Open
1 task done
kujiy opened this issue Apr 4, 2024 · 2 comments
Open
1 task done
Labels
area:typescript issues that specifically impact using the package from typescript projects auto-triage-skip good first issue pkg:web-api applies to `@slack/web-api`

Comments

@kujiy
Copy link

kujiy commented Apr 4, 2024

Packages:

Select all that apply:

  • @slack/web-api

Reproducible in:

The Slack SDK version

    "@slack/web-api": "^7.0.2",

Node.js runtime version

$ node --version
v20.11.1

OS info

$ sw_vers && uname -v
ProductName:            macOS
ProductVersion:         13.6.3
BuildVersion:           22G436
Darwin Kernel Version 22.6.0: Tue Nov  7 21:40:08 PST 2023; root:xnu-8796.141.3.702.9~2/RELEASE_ARM64_T6000

Steps to reproduce:

Create a WebClient instance and call .auth.test() without argument.

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

const api = new WebClient(
            slackBotToken
        );

const botUserInfo: any = await api.auth.test();

Expected result:

// Works without errors
const botUserInfo: any = await api.auth.test();

.auth.test() returns a userinfo of the bot.

Actual result:

It requires an empty dict as an argument.

// Error
const botUserInfo: any = await api.auth.test();  //  error TS2554: Expected 1 arguments, but got 0.

// Works with an empty dict
const botUserInfo: any = await api.auth.test({});

Requirements

I read the requirements and agreed with the rules.

@kujiy kujiy added the untriaged label Apr 4, 2024
@seratch seratch added good first issue area:typescript issues that specifically impact using the package from typescript projects pkg:web-api applies to `@slack/web-api` auto-triage-skip and removed untriaged labels Apr 4, 2024
@seratch
Copy link
Member

seratch commented Apr 4, 2024

Hi @kujiy, thank you for taking the time to provide this feedback!

Indeed, the method does work even without passing an argument, but it is a rare case among the Slack web APIs. For this reason, we generally recommend passing an empty argument object to any methods, which is why the TS typing requires an arugment object.

That being said, we are open to making minor modifications to exceptions such as the api.test and auth.test API methods. I will leave this issue open for potential future enhancements.

@filmaj
Copy link
Contributor

filmaj commented Apr 4, 2024

This change was introduced in web-api v7, and is explicitly detailed in the migration guide for this method, FYI.

That said I agree with @seratch - perhaps we can look into additional code to create an exception for zero-argument methods.

@filmaj filmaj changed the title Mismatch .auth.test() type declaration and implementation. "error TS2554: Expected 1 arguments, but got 0." web-api: Consider removing need to provide empty object as argument to zero-argument methods Apr 4, 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 auto-triage-skip good first issue pkg:web-api applies to `@slack/web-api`
Projects
None yet
Development

No branches or pull requests

3 participants