Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ギークプラス ソフトウェア事業部
June 10, 2026
Programming
620
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
2026/06/10開催のTSKaigi Night Talks 2026の登壇資料
ギークプラス ソフトウェア事業部
June 10, 2026
More Decks by ギークプラス ソフトウェア事業部
See All by ギークプラス ソフトウェア事業部
AI、CDK と協働する Full TypeScript アプリケーション開発 / Full TypeScript Application with AI and CDK
geekplus_tech
2
900
会社説明資料|株式会社ギークプラス ソフトウェア事業部
geekplus_tech
0
2.6k
ソフトウェア事業部のビジョン
geekplus_tech
1
110
インフラを Excel 管理していた組織が 3 ヶ月で IaC 化されるまで
geekplus_tech
3
320
Other Decks in Programming
See All in Programming
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
450
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
1
700
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
110
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
320
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1k
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
330
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.1k
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
190
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
Workers Cache を知る
syumai
0
320
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
JRuby: Past, Present, and Future
headius
0
210
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
BBQ
matthewcrist
89
10k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
540
Documentation Writing (for coders)
carmenintech
77
5.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Deep Space Network (abreviated)
tonyrice
0
350
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Transcript
Moving the world intelligently ©Geekplus Co., Ltd. TypeScriptで サプライチェーンの整合性を 型に閉じ込める
株式会社ギークプラス Soju Kameyama | Web Engineer 2026.06.10
Moving the world intelligently ©Geekplus Co., Ltd. 2 ⾃⼰紹介 ⽒名
⻲⼭ 創樹(Soju Kameyama) 所属 株式会社ギークプラス ソフトウェア事業部 経歴 株式会社インフォマティクス 入社 キヤノン株式会社 入社 KINTOテクノロジーズ株式会社 入社 株式会社ギークプラス 入社 2017 2019 2022 2026 サプライチェーンに関わるお客様の業務を支援するSkylaaの開発を行っています 担当
INDEX Moving the world intelligently ©Geekplus Co., Ltd. 3 1.
同じ事実を別々に持つと、ズレる問題 2. 発想を変えてみる:保存するのは"流れ"だけ 3. まとめ 今回はバックエンドのお話になります
Moving the world intelligently ©Geekplus Co., Ltd. 4 1. 同じ事実を別々に持つと、ズレる問題
設計で悩んだ部分です
「品切れ」が上へさかのぼる例で考える ④発注先の⼯場から納品 (⼯場 → 倉庫) 100個 ⑤⾃社倉庫からお店へ転送 (倉庫 → お店)
100個 ①お店の棚が100個 品切れ!! Moving the world intelligently ©Geekplus Co., Ltd. ②転送依頼 ③発注依頼 この場合のモノの動きは2種類 = 「外部から取り寄せる(発注系)」と「内部で移動(転送 系)」 ⾃社倉庫 取引先メーカー
同じ100個の動きを、別々の表で⾒たい さきほどの“⼀連の流れ” (⼯場→倉庫→お店 / 100個の動き) Moving the world intelligently ©Geekplus
Co., Ltd. 「⼯場への発注リスト(⼯場→倉庫 100)」 「お店への転送リスト(倉庫→お店 100)」 「『品切れをどう埋めたか』全体の流れ」
システムで単純に表現しようとするとこんな感じに 「発注リスト」を保存? 「転送リスト」を保存? 「全体の流れ」も保存? 流れ Moving the world intelligently ©Geekplus
Co., Ltd. → 3つを 別々に組み⽴てて、別々に持つ?? ?
Moving the world intelligently ©Geekplus Co., Ltd. 整合性が崩れる罠 • 「転送リスト」だけ直して他を直し忘れる
→ 発注リスト‧全体の流れとズレる • 表を増やすたびに、 整合チェックのコードも増える 同じ事実を個別に持つと、バグの温床に
Moving the world intelligently ©Geekplus Co., Ltd. 9 2. 発想を変えてみる:保存するのは"流れ"だけに
設計を⾒直しました
話を戻すと さきほどの“⼀連の流れ” (⼯場→倉庫→お店 / 100個の動き) 「⼯場への発注リスト(⼯場→倉庫 100)」 「お店への転送リスト(倉庫→お店 100)」 「『品切れをどう埋めたか』全体の流れ」
Moving the world intelligently ©Geekplus Co., Ltd. どれも同じ「1本の流れ」を別の⾓度で⾒ているだけ →保存するのも1つで良さそう
Moving the world intelligently ©Geekplus Co., Ltd. 発想を変えてみる:流れだけ保存して、表は計算する 保存するのは「流れ」だけで各リストは流れからの計算 =
Reactの「派⽣stateは持たず計算する」と同じで、状態は1つ+表⽰は計算 ⼯場 → 倉庫 → お店 「⼀連の流れ」(唯⼀の正解) 関数で計算 (保存しない) 発注リスト 転送リスト 全体リスト その他記録 保存するやつ 計算で出すやつ ※ 物の移動 物の移動 物の移動 物の移動 物の移動
使う道具は、主に2つ 判別可能ユニオン 「この変数は、何種類かのうちのどれか1つ」という型 type Shape = | { kind: 'circle';
r: number } | { kind: 'square'; size: number } // 種類によってプロパティ構成も変えられる 各種類に⾒分けるためのラベル(タグ)がある 純粋関数 同じ⼊⼒なら、必ず同じ出⼒(外の状態に触れない) const add = (a: number, b: number) => a + b // DB や グローバルオブジェクト には触らない 結果が予測できる → テストが楽、どこでも再利⽤できる この2つを⽤いて 「流れ → 表」 を安全に組み⽴てることができる Moving the world intelligently ©Geekplus Co., Ltd.
流れは、2種類のノードでできた“⽊構造”と捉える 外から取り寄せる(発注) 中で運ぶ(転送) // 流れの中の1ノード(2種類) type Node = | {
kind: 'order'; // 発注 // ...(プロパティは省略) children: Node[] // 次のノード } | { kind: 'transfer'; // 転送 // ...(プロパティは省略) children: Node[] // 次のノード } 「種類は2つのうち1つだけ(判別可能ユニオン)」を型で宣⾔(取り違えはコンパイルエラー) ※スライド⽤に名前を簡略化しています Moving the world intelligently ©Geekplus Co., Ltd.
流れは、2種類のノードでできた“⽊構造”と捉える ※スライド⽤に名前を簡略化しています Moving the world intelligently // ノード定義(流れの中の1ノードにあたり、今回は2種類用意) type Node
= | {kind:'order'; from:string;to:string;qty:number;children:Node[]} | {kind:'transfer'; from:string;to:string;qty:number;children:Node[]} // ①「流れ」をこういう入れ子のオブジェクトに格納(実際には DBから取ってくる) const flow: Node[] = [{ kind: 'order', from: '工場', to: '中央倉庫', qty: 180, children: [ {kind:'transfer',from:'中央倉庫',to:'渋谷店',qty:100,children:[]}, {kind:'transfer',from:'中央倉庫',to:'新宿店',qty: 80,children:[]}, ], },] // ② 木を歩いて、指定した kind のノードだけ集める関数(純粋関数) function collect(nodes: Node[], kind: Node['kind']): Node[] { return nodes.flatMap((n) => [ ...(n.kind === kind ? [n] : []), // ← unionだからkindで絞り込める ...collect(n.children, kind), ]) } // 上記関数を使って注文リスト・配送リストを作成(表示用) const orderList = collect(flow, 'order') // 工場→中央倉庫 const transferList = collect(flow, 'transfer') // 中央倉庫→各店舗
さらに拡張すると(卸売業者パターン) Moving the world intelligently ©Geekplus Co., Ltd. 発注 転送
転送 転送 転送 転送 出荷 出荷 出荷 出荷 複雑な⽊構造も1つの流れとして組み⽴てることができる • 外部の会社に持ち出す「出荷型」を新たにNode定義(内から外) • ⽊構造なので枝分かれも表現できる ex.外部⼯場から親倉庫へ ex.親倉庫から⼦倉庫Aへ ex.⼦倉庫から孫倉庫へ ex.孫倉庫から外部⼩売業者へ ex.親倉庫から⼦倉庫Bへ
Moving the world intelligently ©Geekplus Co., Ltd. 16 3. まとめ
もう少しだけお付き合いください
まとめ ⼀連の物の流れにおいて、状態は1つだけ(⽊構造として)持つようにする そこから派⽣する値は保存せずに計算(純粋関数)で出すようにする 「状態は1つ、表⽰は計算」 → 改修時にズレを直すのではなく起こさないようにする Moving the world intelligently
©Geekplus Co., Ltd.
Moving the world intelligently ©Geekplus Co., Ltd. 18 ありがとうございました
©Geekplus Co., Ltd.