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
TypeScriptの型だけでオセロを完全実装する ── 型は"仕様"をどこまで語れるか
Search
forcia
May 21, 2026
300
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TypeScriptの型だけでオセロを完全実装する ── 型は"仕様"をどこまで語れるか
forcia
May 21, 2026
Featured
See All Featured
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.7k
Optimising Largest Contentful Paint
csswizardry
37
3.8k
Mobile First: as difficult as doing things right
swwweet
225
10k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
340
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
450
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
490
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
150
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Visualization
eitanlees
152
17k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
600
Product Roadmaps are Hard
iamctodd
55
12k
Transcript
TypeScriptの型だけでオセロを完全実装する ── 型は"仕様"をどこまで語れるか 籏野 拓 2026.05.22 TSKaigi2026 -DAY1- RightTouchトラック
Speaker紹介 籏野 拓 @taku-hatano 2 フロントエンド・バックエンド・インフラ すべてをTypeScriptに支えられている
3 フォルシア株式会社
こんな型を見たことはありませんか? 4
5 type TravelReservation = { reservationId: string; status: | "pending"
| "confirmed" | "waitlisted" | "cancelled"; confirmedAt?: Date; cancelledAt?: Date; waitlistPosition?: number; }; 複数の状態が重なり合う型 status: “confirmed”なら confirmedAtは必ず存在するはず …だが型だけ見てもわからない “仕様”を正確に表さない型
本日の主題 : 型で”仕様”を表現するハードルを下げたい 6
もっと複雑な ”仕様”を表現すれば 「あれ、できるかも?」と思ってもらえるかも 7
そうだ、オセロ作ろう
オセロの”仕様”の複雑さ • 8×8の盤面(端、角、それ以外で構成) • “合法手”の判定 • パスの判定 • 石をひっくり返す操作 •
勝敗の判定 • …etc 9
オセロ型の紹介 ~Play型~ 10 type G1 = Play<"e6">; // G2: f4
- e4の黒を挟んで裏返し、 4行目を白で横に支配する type G2 = Play<"f4", G1>; type G3 = Play<"f4", G2>; 型 '"f4"' は制約 '"c3" | "d3" | "e3" | "f3" | "g3"' を満たしていません。 次の手番と今の盤面を渡すと盤面が進む “合法手”でなければエラーになる
オセロ型の紹介 ~View型~ 11 expectTypeOf<V10>().toEqualTypeOf<{ cols: " abcdefgh"; row1: "1|--------|"; row2:
"2|--------|"; row3: "3|---XO---|"; row4: "4|--OXOO--|"; row5: "5|--XXOX--|"; row6: "6|---XO---|"; row7: "7|---X-O--|"; row8: "8|--------|"; }>(); 今の盤面を視覚化する型
オセロ型の紹介 ~BoardResult型~ 12 expectTypeOf<BoardResult<FullBlackBoard>>().toEqualTypeOf<{ blackCount: 64; whiteCount: 0; winner: "black";
}>(); 石の数を数えて勝者を判定する
オセロ型の紹介 気になる方はこちらのリポジトリに実装を置いてます! https://github.com/taku-hatano/othello-type 13
型で作った “仕様”は他人に伝わるのか? 14
よし、AIだ!! 15
AIに「これはどんな型?」を調査させた モデル: Claude Opus 4.7 渡した情報は以下のみ 16 import type {
SecretType } from "./src"; 型名も含めてあらゆる情報がない状態から どのような型か推測できるか?
A. できた 17
型だけで仕様を表現し、他人に伝えることができた! 18 ※先のリポジトリにAIの調査ログをおいてますので 気になる方はそちらを参照してください。
オセロという複雑な ”仕様”を 型で実装できた!! 19
あなたが扱う ”仕様”も 型でもう少しうまく表現できるかも? 20
EOF