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
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
410
Featured
See All Featured
ラッコキーワード サービス紹介資料
rakko
1
5.2M
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
sira's awesome portfolio website redesign presentation
elsirapls
0
440
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
310
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
450
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
620
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
400
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Are puppies a ranking factor?
jonoalderson
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