Closed matthew-dean closed 4 weeks ago
Ideally the two would be unified, tracked in https://github.com/sindresorhus/type-fest/issues/863, but I'm not an expert on these types in particular
I perfer add a new option to output the normal result like arr[0].field
And in the feature, this option maybe can choose to output ['arr', '0', 'field']
or arr[0]['field']
or some useful thing.
A question is which should be the default action?
What do you think? @sindresorhus @voxpelli @matthew-dean
We should add an option to use the arr[0].field
style.
A question is which should be the default action?
It would be nice if it was compatible with Get
by default, but that can be discussed in https://github.com/sindresorhus/type-fest/issues/450
I'm not sure why this is, but the paths produced by
Paths
ends up being slightly different fromGet
. Specifically, it would be nice ifPaths
produced a string array tuple type like:... or with a config option, just:
Instead, it produces only the
{dot}{number}{dot}
form, like:The other problem with
Paths
is that it can't handle a type extended fromRecord
. For example, imagine this very simple use case:This produces the TypeScript error:
Even though we've specified that the record will only have string keys,
Paths
produces something other than a union of strings.It looks like a workaround is:
... but I'm not sure why this should be the case
Upvote & Fund