slackapi / node-slack-sdk

Slack Developer Kit for Node.js
https://tools.slack.dev/node-slack-sdk/
MIT License
3.28k stars 662 forks source link

Incorrect type: `StaticSelect['options']` erroneously allows `MrkdwnElement` #1268

Closed rr-codes closed 3 years ago

rr-codes commented 3 years ago

Description

Describe your issue here.

The following input block has no compile-time type errors, but leads to a Slack BlockKit validation error:

{
   "type":"input",
   "element":{
      "type":"static_select",
      "action_id":"id",
      "options":[
         {
            "text":{
               "type":"mrkdwn",
               "text":"hello"
            },
            "value":"a"
         }
      ]
   }
}

This is because the Option['text'] type is MrkdwnElement | PlainTextElement, when in reality, the payload only supports PlainTextInput.

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

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

seratch commented 3 years ago

Hi @rr-codes, thanks for taking the time to report this (as always)! Indeed, this can be improved in the next release. Perhaps, we can have a new PlainTextOption interface and use it for static_select and others that have the same restriction. https://github.com/slackapi/node-slack-sdk/blob/%40slack/types%402.1.0/packages/types/src/index.ts#L70-L75

rr-codes commented 3 years ago

@seratch awesome! I can implement the change if that works for you?

seratch commented 3 years ago

@rr-codes Yes, we are so glad to have your contribution on this!