One question about PathValue. With your implementation above, we get never with get(user, 'projects.0.name').
PathValue
never
get(user, 'projects.0.name')
But it will get the correct type with one small change:
type Path<T, Key extends keyof T = keyof T> = (Key extends string ? T[Key] extends Record<string, any> ? | `${Key}.${Path<T[Key], Exclude<keyof T[Key], keyof Array<any>>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof Array<any>> & string}` + | Key - | never : never : never)
See here.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
One question about
PathValue
. With your implementation above, we getnever
withget(user, 'projects.0.name')
.But it will get the correct type with one small change:
See here.