slackapi / slackapi/node-slack-sdk

types 3.0: discriminated union types where appropriate

Open
#1,816 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:typescript auto-triage-skip discussion pkg:types semver:major
Dominant language
TypeScript
Stars
3.4k
Forks
688
Avg merge
15h 31m
Merged PRs (30d)
27

Description

This issue comes out of #1227 and has one example of the suggestion to use discriminated unions in the draft PR #1228 (in this commit specifically).

Discriminated union types let us more accurately model certain kinds of either/or and hierarchical constraints. This article is one example goes into more detail about what this is and how to use it.

We also already use it extensively in the web-api package to model certain API request parameter constraints. The classic example where discriminated unions are useful within Slack is when modeling the parameters for the chat.postMessage method. This method requires one of text, blocks or attachments to be present - and with a discriminated union we model this constraint accurately!

Discriminated Union Usage Areas

  • Message Attachments
  • Block Kit - covered by #1905
  • Event Payloads - covered by #1904

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing discriminated-union example in packages/web-api/src/types/request/chat.ts and review the linked chat.postMessage API documentation. Identify the remaining Message Attachments usage area and model its constraints with discriminated unions; the issue's checklist is complete when Message Attachments is covered, while Block Kit and Event Payloads are already covered by #1905 and #1904.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.