Can AutoPath
hint with the top level properties?
#249
Unanswered
timkinnane
asked this question in
Wiki
Replies: 1 comment
-
Wow, okay. I tried a bunch of ideas before making this post, but I did think of one last thing immediately after posting and it seems to work quite well actually. Just needed to also bring in the type IsPath<P extends string> = Length<Split<P, '.'>> extends 1 ? false : true
type StringKeys<T> = Extract<keyof T, string>
type PathOf<T, P extends string> = IsPath<P> extends false
? StringKeys<T>
: AutoPath<T, P> Using the type from my first example, an function argument of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a usage of
AutoPath
where it would be very helpful for developer experience to provide hinting at the top level for a path argument. Currently it seems to only start hinting after the dot, at 2nd tier depth. e.g...With an object of above
Data
type, hinting path argument will work forfoo.
and presentfoo.one
,foo.two
but it would be great if it would first hintfoo
,bar
without any input.I tried combining a basic utility type to join the top level keys with the AutoPath type as below, but it broke all the hinting:
Beta Was this translation helpful? Give feedback.
All reactions