devtypes
    Preparing search index...

    Type Alias PathValue<T, P>

    PathValue: P extends `${infer K}.${infer Rest}`
        ? K extends keyof T ? PathValue<T[K], Rest> : never
        : P extends keyof T ? T[P] : never

    Get a nested value by path (dot notation)

    Type Parameters

    • T
    • P extends string
    type User = { id: number; profile: { name: string; address: { city: string; zip: number } } };
    type CityType = PathValue<User, "profile.address.city">; // number