Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Type Safe "Everything"

Type Safe "Everything"

andoshin11

March 04, 2020
Tweet

More Decks by andoshin11

Other Decks in Technology

Transcript

  1. 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!
  2. • 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? ❤
  3. 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...
  4. 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...
  5. 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
  6. ① 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
  7. ① 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
  8. ② 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
  9. ② Typing API Request/Response (squelette) TODO: • Rewrite remaining ejs

    templates with TS Compiler API • Improve parser and AST format