Skip to content

WebClient arguments and responses are not type safe in TypeScript #1323

@75asa

Description

@75asa

Description

When using chat.postMessage(), I was able to put a non-existent property in ChatPostMessageArguments and the process was executed without a compile error!
(Specifically, I typo icon_url as icon_ur...)
I got a response from @seratch , and it seems that this is largely due to the scope of WebAPICallOptions.
In the future, I'd like to see compilations not go through here, too.

Actual use of ChatPostMessageArguments
methods.d.ts: ChatPostMessageArguments
WebClient.d.ts: WebAPICallOptions

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Packages:

Select all that apply:

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

Reproducible in:

package version: 6.2.4

node version: v16.4.0

OS version(s): MacOS 11.5.2

Steps to reproduce:

  1. import ChatPostMessageArguments from @slack/web-api
  2. define a variable of type ChatPostMessageArguments
  3. define a property that does not exist in ChatPostMessageArguments. like a below code
    const msgOption: ChatPostMessageArguments = {
      channel: Config.Slack.CHANNEL_NAME,
      text,
      foo: "foo", // non-existent property !!
      username: arg.user.name,
      icon_url: arg.user.avatarURL,
      unfurl_links: true,
      blocks: JSXSlack(Header(databaseName!, page)),
    };

Expected result:

What you expected to happen

Actual result:

Compilation will pass.

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Metadata

Metadata

Assignees

Labels

area:typescriptissues that specifically impact using the package from typescript projectsenhancementM-T: A feature request for new functionalitypkg:web-apiapplies to `@slack/web-api`

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions