sindresorhus / type-fest

A collection of essential TypeScript types
Creative Commons Zero v1.0 Universal
13.73k stars 520 forks source link

Unify `Get` and `Paths` / `PickDeep` etc #863

Open voxpelli opened 3 months ago

voxpelli commented 3 months ago

Its a bit odd that we have Get which accepts three styles of specifying paths, but doesn't use Paths, and also have PickDeep etc which use Paths and only accepts a single style of specifying paths.

Desired outcome:

Ideally Get and Paths / PickDeep etc should behave the same when it comes to paths and use the same fundamentals.

Random notes

PickDeep and Get feels fairly similar in other ways as well – maybe one could adapt the internals of PickDeep to also serve Get?

I gave it a look and a try but got a headache and needs to bang my head against something right now.

Upvote & Fund

Fund with Polar

voxpelli commented 3 months ago

Something to keep in mind if one unifies is that ., [, ] are all valid property names of an object, which breaks the text based paths: https://github.com/sindresorhus/type-fest/issues/864

(Also: Symbols are valid properties as well but can't be expressed in any of the two current paths implementations)