to work on
path of O
(?='.'
) delimiter for path
declare function get<O extends object, P extends string>(
object: O, path: AutoPath<O, P>
): Path<O, Split<P, '.'>>
declare const user: User
type User = {
name: string
friends: User[]
}
// works
const friendName = get(user, 'friends.40.name')
const friendFriendName = get(user, 'friends.40.friends.12.name')
// errors
const friendNames = get(user, 'friends.40.names')
const friendFriendNames = get(user, 'friends.40.friends.12.names')
Auto-complete, validate, and query the string path of an object
O