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
430
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
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
590
実践CRDT
tamadeveloper
0
590
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
830
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
300
Swift Concurrency Type System
inamiy
1
550
10 Tips of AWS ~Gen AI on AWS~
licux
5
470
事業会社でのセキュリティ長期インターンについて
masachikaura
1
270
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
610
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
150
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
180
Vibe NLP for Applied NLP
inesmontani
PRO
0
480
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
380
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
110
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
Tell your own story through comics
letsgokoyo
1
900
A Modern Web Designer's Workflow
chriscoyier
698
190k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
190
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Color Theory Basics | Prateek | Gurzu
gurzu
0
300
GraphQLとの向き合い方2022年版
quramy
50
15k
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: … }) } }