Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardTypeScriptcompiler-performance blowupsSingle-choice MCQ

Two type aliases compute the same thing, but one tanks compile performance on large inputs. What property explains the difference?

// Variant A (naive) type RevA<T extends any[]> = T extends [infer H, ...infer R] ? [...RevA<R>, H] : []; // Variant B (tail via accumulator) type RevB<T extends any[], Acc extends any[] = []> = T extends [infer H, ...infer R] ? RevB<R, [H, ...Acc]> : Acc;