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
Type Safe "Everything"
Search
andoshin11
March 04, 2020
Technology
290
0
Share
Type Safe "Everything"
andoshin11
March 04, 2020
More Decks by andoshin11
See All by andoshin11
Introduction to gRPC Interceptors
andoshin11
0
96
カーナベルにおけるProtobuf二次利用例
andoshin11
0
160
Envoy External AuthZとgRPC Extensionを利用した「頑張らない」Microservices認証認可基盤
andoshin11
0
940
カーナベル株式会社2024年2月 エンジニアイベント資料
andoshin11
0
510
Private Cloudを支える最高のユーザーガイド運用技術
andoshin11
0
320
TS CompilerがVueを喋れても良いじゃないか
andoshin11
0
790
ain't giving up type-safe Express
andoshin11
2
490
Hack your Nuxt router!
andoshin11
0
1.4k
GatewayパターンとSchema駆動開発
andoshin11
7
1.5k
Other Decks in Technology
See All in Technology
NgRx SignalStore: The Power of Extensibility
rainerhahnekamp
0
230
AIを共同作業者にして書籍を執筆する方法 / How to Write a Book with AI as a Co-Creator
ama_ch
2
110
プロンプトエンジニアリングを超えて:自由と統制のあいだでつくる Platform × Context Engineering
yuriemori
0
200
終盤で崩壊させないAI駆動開発
j5ik2o
2
2.1k
AWS DevOps Agentはチームメイトになれるのか?/ Can AWS DevOps Agent become a teammate
kinunori
1
250
QGISプラグイン CMChangeDetector
naokimuroki
1
260
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
230
"SQLは書けません"から始まる データドリブン
kubell_hr
2
440
非エンジニア職からZOZOへ 〜登壇がキャリアに与えた影響〜
penpeen
0
460
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
JOAI2026講評会資料(近藤佐介)
element138
1
130
CDK Insightsで見る、AIによるCDKコード静的解析(+AI解析)
k_adachi_01
2
160
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
21k
Skip the Path - Find Your Career Trail
mkilby
1
100
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
54k
Leo the Paperboy
mayatellez
7
1.6k
Code Review Best Practice
trishagee
74
20k
Visualization
eitanlees
150
17k
Raft: Consensus for Rubyists
vanstee
141
7.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
510
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.2k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
270
Transcript
Type Safe “EVERYTHING” @andoshin11 4. 3. 2020 #tsc_api_study
Who am I ? Shin Ando (a.k.a Andy) @andoshin11 -
Freelance Full-Stack Developer - TypeScript / Vue.js / React / Go / Ruby / Flutter / Terraform / etc… - ❤ Code Generation!
• Powerful editor completion • Easy to analyze code base
using AST • Type-level programming • Overall durability • Maintainable • Scalable • F**king AWESOME!! We all love TypeScript, eh? ❤
However...
Not everyone speaks TypeScript (just yet...)
Not everyone speaks TypeScript (just yet...) • Other programming languages
(Go, Ruby, Python, Java, etc...) • Query based languages (a.k.a Database) • Statically defined specs (YAML, CSV, Markdown, Excel) • etc...
Not everyone speaks TypeScript (just yet...) • Other programming languages
(Go, Ruby, Python, Java, etc...) • Query based languages (a.k.a Database) • Statically defined specs (YAML, CSV, Markdown, Excel) • etc...
Solution (we need)
Basic aproach Parser Transformer TS Compiler 1. Parse input and
tokenize into JSON 2. Transform tokens to TypeScript AST 3. Validate AST and emit useful code Outcome
None
Working Projects
① Typing Database Schema (db-recon) • db-recon ( https://github.com/andoshin11/db-recon )
• Generates type-safe db client for Node.js application • Supports MySQL and MSSQL currently
① Typing Database Schema (db-recon)
① Typing Database Schema (db-recon)
① Typing Database Schema (db-recon)
① Typing Database Schema (db-recon) TODO: • Create SQL-to-AST parser
• Get semantic diagnostics for raw SQL literal string ( ts-sql-plugin requires DSL ) • Rewrite ejs templates with TS Compiler API
② Typing API Request/Response (squelette) • squelette ( https://github.com/andoshin11/squelette )
• Generates type definitions for API request/response from Open API spec • Toolchain to build your own type-safe API client
② Typing API Request/Response (squelette)
② Typing API Request/Response (squelette)
② Typing API Request/Response (squelette)
② Typing API Request/Response (squelette)
② Typing API Request/Response (squelette) TODO: • Rewrite remaining ejs
templates with TS Compiler API • Improve parser and AST format
Latest addition
Improving DX for express.js
Remaining Pains...
Remaining Pains... need manual mapping need to define types may
contain typo
Leads to fatal error in future...
What if...
All handlers are typed like a magic ♂
None
Introducing...
typed-oax
Generate express.d.ts from Open API
Generate express.d.ts from Open API
Generate express.d.ts from Open API
DEMO
typed-oax TODO: • Separate handler types by HTTP Method •
Wrap with TS Plugin?