3 ms·
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'] exte
by nkrisc 4y ago
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
}