-
Notifications
You must be signed in to change notification settings - Fork 680
Open
Labels
area:typescriptissues that specifically impact using the package from typescript projectsissues that specifically impact using the package from typescript projectsauto-triage-skipdiscussionM-T: An issue where more input is needed to reach a decisionM-T: An issue where more input is needed to reach a decisionpkg:typesapplies to `@slack/types`applies to `@slack/types`semver:major
Milestone
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 types 3.0: breaking changes for block kit types #1905
- Event Payloads - covered by types 3.0: breaking change for event payloads #1904
Metadata
Metadata
Assignees
Labels
area:typescriptissues that specifically impact using the package from typescript projectsissues that specifically impact using the package from typescript projectsauto-triage-skipdiscussionM-T: An issue where more input is needed to reach a decisionM-T: An issue where more input is needed to reach a decisionpkg:typesapplies to `@slack/types`applies to `@slack/types`semver:major