#1502·type-fest

bug: constraint on PathUnion in PickDeep

Author: salisbury-espinosaCreated Aug 15, 2026Updated Aug 15, 2026
Labelsbug

Bug description

typescript
import type { Get, Paths, PickDeep } from 'type-fest';

type FieldType = {
  bar?: boolean;
  foo: string;
};

type Test = {
  foo?: Array<
    | {
        mode: 'test1';
        bar: Array<{
          foo: Array<FieldType> | FieldType;
        }>;
      }
    | {
        mode: 'test2';
        foo: boolean;
        bar: Array<{
          foo: Array<FieldType> | FieldType;
        }>;
      }
  >;
};

type PathsType = Paths<
  Test,
  {
    maxRecursionDepth: 10;
    leavesOnly: false;
  }
>;

// ok
`foo.0.bar.0.foo.0.bar` as const satisfies PathsType;


// ===> `TS2344: Type '`foo.${number}.bar.${number}.foo.${number}.bar`' does not satisfy the constraint`
true satisfies Get<
  PickDeep<Test, `foo.${number}.bar.${number}.foo.${number}.bar`>,
  `foo.${number}.bar.${number}.foo.${number}.bar`
>;

workaround for demonstration:

https://github.com/sindresorhus/type-fest/blob/main/source/pick-deep.d.ts#L67C25-L67C34

==>

patch
@@ -64,7 +64,9 @@ type Street = PickDeep<Configuration, 'userConfig.address.1.street2'>;
 @category Object
 @category Array
 */
-export type PickDeep<T, PathUnion extends Paths<T>> =
+export type PickDeep<T, PathUnion extends Paths<T> | Paths<T, {
+	maxRecursionDepth: 10;
+}>> =
 	T extends NonRecursiveType
 		? never
 		: T extends UnknownArray

Repro

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBDAnmApnA3nA4imAaOABQEMYALAZwMOAGMBrAERRTDgF84AzKCEOAORJUAWi4oKMAQG4AsACgFwtADFgKADYATACrI0AXgwK4cAEbEoAfgBc5iBA0piAOznzTXB3clRgLgHN3dnclfTgdCXgjdBNuB1s4AEEoKGJEAB440wAfYw9TQtMQCC0UOyEogEYZbKLzSzsUtMzYgvrCrwgm1PSMtU1dfQA+ODyB7T1Udw7TdmGZ+vY6vLbZuBKyipgogCZa9vquuzMHJ1dFjosoHpaMtfX47uTezImh1FHx9Un9S6WFnU5nFAfIQgowqgiKRKFNDNDyBQsgVIpI8HEHsViAAPABKKFoAFcoBRgBAXMwwOQ7FUAAz-c4ANwkAHkXBpEHYuMQNBQUItlvJQQoAAZdAB0tPF10l4olUuuIrgxAocFo5MkcAopGAFC46lVJERcNC8hgUEJaG1MF1+ok2FwyNMNAYzFYGVR+DgYoc4oAJOgXISQGYUFB2NLLP7A8HQ+G5b6A0GQ2GI4rhuiCj6INHk3G01Gk7HUwmc0WU-HFQoFkA