Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TypeScript で型検査器を作る / Implementing a type check...
Search
katashin
June 09, 2017
Programming
0
22k
TypeScript で型検査器を作る / Implementing a type checker with TypeScript
katashin
June 09, 2017
Tweet
Share
More Decks by katashin
See All by katashin
テストの重要性 / Test is Important
ktsn
0
200
console.animate
ktsn
2
2.7k
Gulp のビルドをもっと効率化するツールを作ってみた / Making a Tool for Optimizing a Build Process of Gulp
ktsn
2
2.5k
ラムダ計算入門 / Introduction of Lambda Calculus
ktsn
0
390
Contextual ThisType and Vue.js
ktsn
0
13k
大規模静的サイトのためのビルドツール
ktsn
0
2.3k
型付きテンプレートがほしい
ktsn
1
44k
Toward Type Safety of Vuex
ktsn
1
1k
Vue の TypeScript 事情
ktsn
1
2.6k
Other Decks in Programming
See All in Programming
chocoZAPサービス予約システムをNuxtで内製化した話
rizap_tech
0
160
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
170
これならできる!個人開発のすゝめ
tinykitten
PRO
0
110
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
150
Go コードベースの構成と AI コンテキスト定義
andpad
0
130
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.9k
Why Kotlin? 電子カルテを Kotlin で開発する理由 / Why Kotlin? at Henry
agatan
2
7.3k
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
720
Cell-Based Architecture
larchanjo
0
130
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
SwiftUIで本格音ゲー実装してみた
hypebeans
0
410
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.2k
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Unsuck your backbone
ammeep
671
58k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Faster Mobile Websites
deanohume
310
31k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Done Done
chrislema
186
16k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
730
The World Runs on Bad Software
bkeepers
PRO
72
12k
A Tale of Four Properties
chriscoyier
162
23k
Designing for Performance
lara
610
69k
Transcript
5ZQF4DSJQUͰܕݕࠪثΛ࡞Δ ܕษڧձ
ܕݕࠪث w ͋Δܭࢉମܥʹ͓͚Δ߲ͷܕΛಋग़͢Δ w ܕ͚نଇʹͯ·Βͳ͍߲͕ଘࡏ͢Δ࣌ ΤϥʔΛ͛Δ
+BWB4DSJQUͷܕݕࠪثΛ ࡞ͬͯΈΔ w ඞཁʹഭΒΕͨͷͰʜʜ w ߏจ&TQSJNBͱ͔ΛͬͯಘΔ͜ͱ͕Ͱ͖Δ w 5ZQF4DSJQUͷܕใΛదٓ༗ޮ׆༻͢Δ w ؆୯ͷͨΊʹɺ߲෭࡞༻Λ࣋ͨͳ͍ͷͱ͢Δ
"45&YQMPSFS IUUQTBTUFYQMPSFSOFU
ܕ͚نଇͷྫ • true: boolean • t: string ∧ u: U
→ (t + u): string • t: T ∧ u: T → (t === u): boolean • t: { u: U } → t.u: U ˢΛͦͷ··࣮͢Ε0,
είʔϓ w ݱࡏݕ͍ࠪͯ͠Δ߲Ͱར༻ՄೳͳมͷҰཡΛ ͓࣋ͬͯ͘ඞཁ͕͋ΔͷͰɺ function typeOf(ast: ESTree.Node, scope: Var[]): Type
Έ͍ͨͳײ͡ʹͳΔ
ΤϥʔΛूΊΔ w ܕ͚نଇʹͯ·Βͳ͍࣌ʹΤϥʔΛ͛Δ ͷͰͳ͘ɺจ຺ʹΤϥʔΛՃ͢Δ w ϝοηʔδιʔείʔυ্ͷॴΛ༩͢Δͱศར ΤσΟλʔͱ͔ͰઢΛҾ͚Δ
શମ૾ function typeOf(ast: ESTree.Node, scope: Var[]) { switch (ast.type) {
case ‘BinaryOperator’: // … case ‘…’: default: this.errors.push({ message: ‘…’, start: …, end: … }) } }