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
320
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
1k
カーナベル株式会社2024年2月 エンジニアイベント資料
andoshin11
0
560
Private Cloudを支える最高のユーザーガイド運用技術
andoshin11
0
330
TS CompilerがVueを喋れても良いじゃないか
andoshin11
0
820
ain't giving up type-safe Express
andoshin11
2
520
Hack your Nuxt router!
andoshin11
0
1.5k
GatewayパターンとSchema駆動開発
andoshin11
7
1.6k
Other Decks in Technology
See All in Technology
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.5k
RapidCopy2 Matrix I/Oエンジンによるファイルコピーソフトウェアの設計と実装
kengosawa2
1
410
Digitization部 紹介資料
sansan33
PRO
2
7.7k
Kiro5兄弟のいまどきのセキュリティ基礎知識
kentapapa
0
250
作って理解するCoding Agent 〜フレームワークに頼らないピュア Python での実装〜
takapy
4
1.3k
型落ちシンクライアント端末のPoEモジュールを自作したかった話
logica0419
0
440
ClaudeCodeでセキュリティ監視業務を半自動化_1年の運用でわかったAIに任せる設計の5つのポイント
kintotechdev
3
340
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.3k
Windows の互換機能 - 古いプログラムはなぜ動作できるのか
murachiakira
PRO
0
100
「ミスを許さない手順書」を作ってみた 〜 個人的にはこれ以上できることはあまりなさそう/20260827-ssmjp-operation-procedure-update
opelab
2
440
長期運営で肥大化したExcelマスターデータの解消に向けた移行事例
gree_tech
PRO
0
510
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
77k
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
480
Test your architecture with Archunit
thirion
2
2.4k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
GraphQLとの向き合い方2022年版
quramy
50
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
280
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Ethics towards AI in product and experience design
skipperchong
2
350
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
360
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
250
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?