Annotated solution
Published September 10, 2026The solution
type TupleToObject<T extends readonly PropertyKey[]> = { [K in T[number]]: K }The common wrong answer
type TupleToObject<T extends readonly PropertyKey[]> = { [K in keyof T]: T[K] }Mapping over keyof T when T is a tuple gives you a *tuple* back, not an object — the mapping is homomorphic, so it preserves the arrayness along with everything else. ["a", "b"] maps to ["a", "b"], which is a perfectly good answer to a question nobody asked.
Line by line
T[number]Indexing a tuple by
numberasks for "the type at any index", which is the union of everything in it:"a" | "b". That union is the key set you actually want to iterate.{ [K in T[number]]: K }Because the key set is computed rather than
keyof T, the mapping is no longer homomorphic — and that is exactly why the result comes back as a plain object.
Takeaway
keyof T on a tuple means its indices; T[number] means its contents. Reaching for the wrong one turns an object into a tuple, or the other way round, and the error message rarely says so.

