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 checker with TypeScript
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
180
console.animate
ktsn
2
2.5k
Gulp のビルドをもっと効率化するツールを作ってみた / Making a Tool for Optimizing a Build Process of Gulp
ktsn
2
2k
ラムダ計算入門 / Introduction of Lambda Calculus
ktsn
0
250
Contextual ThisType and Vue.js
ktsn
0
13k
大規模静的サイトのためのビルドツール
ktsn
0
2.1k
型付きテンプレートがほしい
ktsn
1
43k
Toward Type Safety of Vuex
ktsn
1
940
Vue の TypeScript 事情
ktsn
1
2.6k
Other Decks in Programming
See All in Programming
Milestoner
bkuhlmann
1
410
try!Swift Tokyo 2024 参加報告 LT
akidon0000
1
220
PHPはいつから死んでいるかの調査
chiroruxx
1
380
PostmanでAPIの動作確認が楽になった話
h455h1
0
160
エンターテイメント業界で利用されるAWS
demuyan
0
210
Rethinking UI building strategies @ SFI 2024
letelete
0
270
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
160
コードレビューで学ぶ!Kotlinオブジェクト指向デザインパターン
akkie76
2
200
try! Swift Tokyo 初参加報告LT
hinakko2
0
220
サイコロで理解する統計的仮説検定の考え方
tatamiya
4
890
Elm Form Validation
bkuhlmann
0
510
Netty Chicago Java User Group 2024-04-17
sullis
0
170
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
Making Projects Easy
brettharned
108
5.5k
Building a Scalable Design System with Sketch
lauravandoore
456
32k
Code Reviewing Like a Champion
maltzj
514
39k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
Typedesign – Prime Four
hannesfritz
36
2.1k
Faster Mobile Websites
deanohume
299
30k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Building Your Own Lightsaber
phodgson
99
5.7k
How to name files
jennybc
65
93k
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: … }) } }