~/talk

Building Strongly Typed REST Clients with Typescript

Talkat OpenJS World 2021 · 2021-06-02..06-03· [typescript]
links:none on file
slides:none on file

Builds a type-safe client for a book-catalog REST API (paths /book and /book/{bookId} supporting GET/POST/PUT and GET/DELETE) using TypeScript template literal types and a recursive path-parameter extractor to turn URL templates into positional function parameters. Maps each path to operation-specific request and response types (status code string literals, body shapes, headers), uses tuple/rest types for required params, and demonstrates working editor completions and narrowing so callers get correct payload fields and precise response types.

AI-written summary · about

  1. 0:00Introduction to talk
  2. 0:43REST API overview
  3. 1:47Setting up the client
  4. 3:41Limiting path options
  5. 5:33Detecting path parameters
  6. 9:29Handling required parameters
  7. 13:28Finalizing path function
  8. 15:23Adding API methods
  9. 17:10Defining response types
  10. 19:38Implementing response types
  11. 21:05Exploring response shapes
  12. 22:52Error handling with types
  13. 23:57Adding input parameters
  14. 25:22Building request payload
  15. 25:46Demo and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.