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
TypeScriptの型だけでオセロを完全実装する ── 型は"仕様"をどこまで語れるか
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
forcia
May 21, 2026
350
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TypeScriptの型だけでオセロを完全実装する ── 型は"仕様"をどこまで語れるか
forcia
May 21, 2026
More Decks by forcia
See All by forcia
フォルシア株式会社_会社説明資料.pdf
forcia
0
300
Featured
See All Featured
Scaling GitHub
holman
464
140k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
270
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
670
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Faster Mobile Websites
deanohume
310
32k
The Spectacular Lies of Maps
axbom
PRO
1
990
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
We Have a Design System, Now What?
morganepeng
55
8.3k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.3k
We Are The Robots
honzajavorek
0
370
Test your architecture with Archunit
thirion
2
2.4k
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