types 3.0: discriminated union types where appropriate #1816
Labels
area:typescript
issues that specifically impact using the package from typescript projects
auto-triage-skip
discussion
M-T: An issue where more input is needed to reach a decision
pkg:types
applies to `@slack/types`
semver:major
Milestone
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 thechat.postMessage
method. This method requires one oftext
,blocks
orattachments
to be present - and with a discriminated union we model this constraint accurately!Discriminated Union Usage Areas
The text was updated successfully, but these errors were encountered: