Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合...
Search
ギークプラス ソフトウェア事業部
June 10, 2026
Programming
450
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
480
会社説明資料|株式会社ギークプラス ソフトウェア事業部
geekplus_tech
0
1.1k
ソフトウェア事業部のビジョン
geekplus_tech
1
85
インフラを Excel 管理していた組織が 3 ヶ月で IaC 化されるまで
geekplus_tech
3
280
Other Decks in Programming
See All in Programming
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
160
関数型プログラミングのメリットって何だろう?
wanko_it
0
190
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
230
AIが無かった頃の素敵な出会いの話
codmoninc
1
200
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.9k
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
430
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
390
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
690
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.6k
霧の中の代数的エフェクト
funnyycat
1
420
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
900
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
280
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
220
Are puppies a ranking factor?
jonoalderson
1
3.7k
The Limits of Empathy - UXLibs8
cassininazir
1
530
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
360
A Modern Web Designer's Workflow
chriscoyier
698
190k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
390
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
New Earth Scene 8
popppiees
3
2.4k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
190
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.