Hacker News new | ask | show | jobs
by DangitBobby 1154 days ago
It's not just you. To learn how to express more advanced types (or learn whether they are even possible to express), I've had to Google, read source code, or scan random medium articles and blogs from tech companies. Rarely have I learned anything new from the TS docs.
1 comments

I learned more from this type definition than anything I’ve ever read about TypeScript’s type system before:

  interface add extends F { out: this['args'] extends   [infer a, infer b]     ?
  a extends Zero         ? b :
  a extends Suc<infer n> ? Suc<apply<add, [n, b]>> : 

  never : never
}