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
0
280
Type Safe "Everything"
andoshin11
March 04, 2020
Tweet
Share
More Decks by andoshin11
See All by andoshin11
Introduction to gRPC Interceptors
andoshin11
0
86
カーナベルにおけるProtobuf二次利用例
andoshin11
0
160
Envoy External AuthZとgRPC Extensionを利用した「頑張らない」Microservices認証認可基盤
andoshin11
0
920
カーナベル株式会社2024年2月 エンジニアイベント資料
andoshin11
0
500
Private Cloudを支える最高のユーザーガイド運用技術
andoshin11
0
310
TS CompilerがVueを喋れても良いじゃないか
andoshin11
0
780
ain't giving up type-safe Express
andoshin11
2
480
Hack your Nuxt router!
andoshin11
0
1.4k
GatewayパターンとSchema駆動開発
andoshin11
7
1.5k
Other Decks in Technology
See All in Technology
Cortex Code CLI と一緒に進めるAgentic Data Engineering
__allllllllez__
0
600
大規模ECサイトのあるバッチのパフォーマンスを改善するために僕たちのチームがしてきたこと
panda_program
1
340
Agent Skill 是什麼?對軟體產業帶來的變化
appleboy
0
190
エンジニアリングマネージャーの仕事
yuheinakasaka
0
130
2026年もソフトウェアサプライチェーンのリスクに立ち向かうために / Product Security Square #3
flatt_security
1
740
君はジョシュアツリーを知っているか?名前をつけて事象を正しく認識しよう / Do you know Joshua Tree?
ykanoh
2
110
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
3
13k
20260321_エンベディングってなに?RAGってなに?エンベディングの説明とGemini Embedding 2 の紹介
tsho
0
150
A Casual Introduction to RISC-V
omasanori
0
540
20260320_JaSST26_Tokyo_登壇資料.pdf
mura_shin
0
110
形式手法特論:SMT ソルバで解く認可ポリシの静的解析 #kernelvm / Kernel VM Study Tsukuba No3
ytaka23
1
730
夢の無限スパゲッティ製造機 #phperkaigi
o0h
PRO
0
330
Featured
See All Featured
Designing for Timeless Needs
cassininazir
0
170
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Embracing the Ebb and Flow
colly
88
5k
How GitHub (no longer) Works
holman
316
150k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
88
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Are puppies a ranking factor?
jonoalderson
1
3.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Mobile First: as difficult as doing things right
swwweet
225
10k
Documentation Writing (for coders)
carmenintech
77
5.3k
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?