Type Safe "Everything"

Type Safe "Everything"

5c97d6b5611feeebc345c3e4742a05a8?s=128

andoshin11

March 04, 2020
Tweet

Transcript

  1. 2.

    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. 3.

    • 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. 6.

    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. 7.

    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. 9.

    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. 10.
  7. 12.

    ① 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
  8. 16.

    ① 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
  9. 17.

    ② 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
  10. 22.

    ② Typing API Request/Response (squelette) TODO: • Rewrite remaining ejs

    templates with TS Compiler API • Improve parser and AST format
  11. 30.
  12. 32.
  13. 36.