Annotated solution
Published August 5, 2026The solution
type Includes<T extends readonly unknown[], U> = T extends readonly [infer H, ...infer R] ? Equal<H, U> extends true ? true : Includes<R, U> : false
The common wrong answer
type Includes<T extends readonly unknown[], U> = U extends T[number] ? true : false
Short and wrong. `T[number]` is the union of element types and `extends` asks about assignability, so `Includes<[boolean], true>` answers `true` — `true` is assignable to `boolean` even though the tuple contains no such element. Assignability is not membership.
Line by line
Equal<H, U> extends true`Equal` returns the type `true` or the type `false`, so it has to be tested with `extends true` rather than used directly as a condition. This is the puzzle where the harness itself becomes a tool.
: falseReaching the empty tuple means every element was checked and none matched. Exhausting the list *is* the negative answer.
Takeaway
When a puzzle says "exactly", `extends` is the wrong tool — it tests assignability, which is one-directional. Exact identity needs `Equal`, and this is why every check on this site is built on it.