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
370
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
400
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
610
Building an army of robots
kneath
307
47k
Fireside Chat
paigeccino
43
4k
Navigating Weather and Climate Data
rabernat
0
550
Producing Creativity
orderedlist
PRO
348
41k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Automating Front-end Workflow
addyosmani
1369
210k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
260
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
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