Annotated solution
Published September 18, 2026The solution
type GreaterThan<A extends number, B extends number, C extends unknown[] = []> = C['length'] extends A ? false : C['length'] extends B ? true : GreaterThan<A, B, [...C, unknown]>
The common wrong answer
type GreaterThan<A extends number, B extends number, C extends unknown[] = []> = C['length'] extends B ? true : C['length'] extends A ? false : GreaterThan<A, B, [...C, unknown]>
Both tests are right; the order is not. When `A` and `B` are equal the counter reaches them on the same step, and whichever question is asked first wins. Asking about `B` first answers `true` for `GreaterThan<2, 2>` — equal is reported as greater, and only the equality case ever reveals it.
Line by line
C['length'] extends A ? falseReaching `A` first means `B` is at least as large, so `A` cannot be strictly greater. Putting this branch first is what makes the comparison strict rather than "greater or equal".
[...C, unknown]One tick of the counter. The tuple is never read — only its length is — so it is the cheapest possible way to hold a number that can go up by one.
GreaterThan<0, 5>The counter starts at zero, so this is decided before a single step is taken: `A` is reached immediately and the answer is `false`.
Takeaway
When two conditions can fire on the same step, their order is the specification. Comparison types are almost always correct on the unequal cases and wrong on the tie.

