types 3.0: discriminated union types where appropriate

オープン
#1,816 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@filmaj がすでに取り組んでいます。

2024年8月30日 から。

  • #1911 @filmaj による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript
領域
api

調査の方向性

packages/web-api/src/types/request/chat.ts にある既存の判別付きユニオンの例から始め、リンクされている chat.postMessage API のドキュメントを確認してください。残っている Message Attachments の使用領域を特定し、その制約を判別付きユニオンでモデル化してください。Message Attachments がカバーされれば issue のチェックリストは完了です。一方、Block Kit と Event Payloads はすでに #1905 と #1904 でカバーされています。

索引モデルが issue の本文から書いたものです。

説明

area:typescript auto-triage-skip discussion pkg:types semver:major

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
主要言語
TypeScript
スター
3.4k
フォーク
693
平均マージ
1日 1時間
マージ済み PR(30日)
67

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

slackapi/node-slack-sdk のほかの issue

slackapi/node-slack-sdk の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。