`AutoPath` not working?
Author: yaquawaCreated Jan 11, 2022Updated Jul 31, 2024
I've just tried the code exactly as same as in the doc, but seems like it won't work.
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, 'FFFFFFFFF') // this won't give any error
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')
Source: millsp/ts-toolbelt