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 で型検査器を作る / Implementing a type check...
Search
katashin
June 09, 2017
Programming
22k
0
Share
TypeScript で型検査器を作る / Implementing a type checker with TypeScript
katashin
June 09, 2017
More Decks by katashin
See All by katashin
テストの重要性 / Test is Important
ktsn
0
210
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
440
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
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
420
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
GoogleCloudとterraform完全に理解した
terisuke
1
200
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
460
AIエージェントの隔離技術の徹底比較
kawayu
0
270
関係性から理解する"同一性"の型用語たち
pvcresin
1
250
RailsTokyo 2026#4: AI様があれば、 Hotwireの弱点は消えるか?
naofumi
3
440
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
130
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
370
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
430
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
160
Are We Really Coding 10× Faster with AI?
kohzas
0
200
Featured
See All Featured
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
44k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
150
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
230
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
440
How to make the Groovebox
asonas
2
2.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.1k
We Have a Design System, Now What?
morganepeng
55
8.1k
Making Projects Easy
brettharned
120
6.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
200
Discover your Explorer Soul
emna__ayadi
2
1.1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
180
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: … }) } }