From bcaa0b7470e8a1fddab74db096cf93a70d5836a2 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 26 Feb 2019 18:23:48 -0500 Subject: [PATCH] Don't worry about empty tuple types in TupleToIntersection. (#4502) Although a zero-argument call to `mergeDeep` was always pretty pointless, it seemed worth handling that case for the sake of completeness. Well, apparently empty tuple types are forbidden by section 3.8.5 of the TypeScript spec, so (some versions of) the compiler complain about the `[]` in the `T extends []` case of `TupleToIntersection`: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#385-tuple-type-literals Since we never really needed this case in the first place, the easy solution is to remove it. Note that the final cases in `TupleToIntersection` continue to cover the zero-argument case, for whatever it may be worth: T extends (infer U)[] ? U : any Should fix #4501. --- packages/apollo-utilities/src/util/mergeDeep.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/apollo-utilities/src/util/mergeDeep.ts b/packages/apollo-utilities/src/util/mergeDeep.ts index 237e9d1ee40..d83a33fe1df 100644 --- a/packages/apollo-utilities/src/util/mergeDeep.ts +++ b/packages/apollo-utilities/src/util/mergeDeep.ts @@ -15,7 +15,6 @@ const { hasOwnProperty } = Object.prototype; // true & false, and the inferred type ends up as unknown in many cases), // in addition to being nearly impossible to explain/understand. export type TupleToIntersection = - T extends [] ? {} : T extends [infer A] ? A : T extends [infer A, infer B] ? A & B : T extends [infer A, infer B, infer C] ? A & B & C :