bug: constraint on PathUnion in PickDeep
Author: salisbury-espinosaCreated Aug 15, 2026Updated Aug 15, 2026
Labelsbug
Bug description
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
==>
@@ -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 UnknownArrayRepro
Source: sindresorhus/type-fest