Closed quantizor closed 2 years ago
@probablyup yeah you are right, we can now improve typings. When I switch the library on TypeScript it was just released, I didn't wanted to rely on it. But now it is possible!
@gregberge I saw this article recently, might have better perf compared to the previous solution: https://javascript.plainenglish.io/advanced-typescript-type-level-nested-object-paths-7f3d8901f29a
It specifically mentions handling recursion better which is why the previous one was backed out I think
Using newer techniques in TS 4.1 we can acquire an exact list of string paths for helpers like
th.color
.For example, this TS type helper:
Can be used to extract theme values from a type:
And then can be used in the
th.color
helper for example: