Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Type Safe "Everything"
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
andoshin11
March 04, 2020
Technology
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Type Safe "Everything"
andoshin11
March 04, 2020
More Decks by andoshin11
See All by andoshin11
Introduction to gRPC Interceptors
andoshin11
0
130
カーナベルにおけるProtobuf二次利用例
andoshin11
0
180
Envoy External AuthZとgRPC Extensionを利用した「頑張らない」Microservices認証認可基盤
andoshin11
0
1.1k
カーナベル株式会社2024年2月 エンジニアイベント資料
andoshin11
0
570
Private Cloudを支える最高のユーザーガイド運用技術
andoshin11
0
330
TS CompilerがVueを喋れても良いじゃないか
andoshin11
0
830
ain't giving up type-safe Express
andoshin11
2
530
Hack your Nuxt router!
andoshin11
0
1.5k
GatewayパターンとSchema駆動開発
andoshin11
7
1.6k
Other Decks in Technology
See All in Technology
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
7
5.8k
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
170
夫婦で子育てするための育児標準化
codmoninc
PRO
0
190
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
560
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
390
味覇で作るパスタが美味い - 20261001_yabaubuki.dev
livesense
PRO
0
130
会社説明資料
persolserverworks
0
9.7k
Essential architectural thinking (revised edition)
ufried
0
110
契約書画像からの情報抽出に特化した視覚接地モデルを育てる話
sansantech
PRO
1
170
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
880
「事実」を「計測」して、「解釈」する 〜AWS Lambdaのメモリ最適解の見つけ方〜
maimyyym
0
140
Loop Engineering これくらいでいい
mikanichinose
0
230
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
900
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Abbi's Birthday
coloredviolet
4
10k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
The Cost Of JavaScript in 2023
addyosmani
55
10k
Statistics for Hackers
jakevdp
799
230k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Discover your Explorer Soul
emna__ayadi
2
1.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
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?