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
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.4k
ラムダ計算入門 / Introduction of Lambda Calculus
ktsn
0
370
Contextual ThisType and Vue.js
ktsn
0
13k
大規模静的サイトのためのビルドツール
ktsn
0
2.3k
型付きテンプレートがほしい
ktsn
1
44k
Toward Type Safety of Vuex
ktsn
1
980
Vue の TypeScript 事情
ktsn
1
2.6k
Other Decks in Programming
See All in Programming
Let's Write a Train Tracking Algorithm
twocentstudios
0
220
NetworkXとGNNで学ぶグラフデータ分析入門〜複雑な関係性を解き明かすPythonの力〜
mhrtech
3
940
Back to the Future: Let me tell you about the ACP protocol
terhechte
0
120
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
2
310
株式会社 Sun terras カンパニーデック
sunterras
0
180
Web Components で実現する Hotwire とフロントエンドフレームワークの橋渡し / Bridging with Web Components
da1chi
2
1.5k
そのpreloadは必要?見過ごされたpreloadが技術的負債として爆発した日
mugitti9
2
2.8k
猫と暮らすネットワークカメラ生活🐈 ~Vision frameworkでペットを愛でよう~ / iOSDC Japan 2025
yutailang0119
0
210
XP, Testing and ninja testing ZOZ5
m_seki
1
200
AIで開発生産性を上げる個人とチームの取り組み
taniigo
0
130
実践AIチャットボットUI実装入門
syumai
7
2.4k
麻雀点数計算問題生成タスクから学ぶ Single Agentの限界と Agentic Workflowの底力
po3rin
5
2k
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
RailsConf 2023
tenderlove
30
1.2k
Agile that works and the tools we love
rasmusluckow
331
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
How STYLIGHT went responsive
nonsquared
100
5.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Automating Front-end Workflow
addyosmani
1371
200k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
45
2.5k
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: … }) } }