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.5k
ラムダ計算入門 / Introduction of Lambda Calculus
ktsn
0
400
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
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
420
Fluid Templating in TYPO3 14
s2b
0
130
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
180
Architectural Extensions
denyspoltorak
0
280
AI時代の認知負荷との向き合い方
optfit
0
150
SourceGeneratorのススメ
htkym
0
190
Grafana:建立系統全知視角的捷徑
blueswen
0
330
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
640
CSC307 Lecture 09
javiergs
PRO
1
830
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6k
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
Apache Iceberg V3 and migration to V3
tomtanaka
0
150
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
4.9k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
55
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
140
What's in a price? How to price your products and services
michaelherold
247
13k
A better future with KSS
kneath
240
18k
For a Future-Friendly Web
brad_frost
182
10k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
79
Chasing Engaging Ingredients in Design
codingconduct
0
110
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
The browser strikes back
jonoalderson
0
360
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
52k
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: … }) } }