#Adapt KeyPaths<> type helper to accept partials
1 messages · Page 1 of 1 (latest)
Preview:ts ... type A = KeyPaths<typeof x>; // ^? type B = KeyPaths<DeepPartial<typeof x>> // ^? ...
Preview:ts ... type KeyPaths<T> = { [K in keyof T & string]: T[K] extends | object | undefined ? `${K}.${KeyPaths<T[K] & {}>}` : K }[keyof T & string] ...
@safe helm
| undefined + & {}
the other common methods (Required<T>[K], NonNullable<T[K]>) seems to trigger a ts(2589)
!:2589
Yes I was seeing the deep and possibly infinite error
the other way to avoid that error is to do TheProblematicType extends infer T ? DoTheThing<T> : never
but in this case & {} is probably way simpler
I've been at work 10 hours, brain is tired. Where does the & {} go?
@safe helm
The original code I shared has & {}, the new code you shared seems to add only | undefined? Am I being blind?
UPDATE: Yes, I was being blind, there's an & {} added after the first ?
Maybe my other quesiton I just asked will make it clearer, because it shows the intended usage. When I tried to use your suggestion above (thank you) it broke for me (in the other question https://discord.com/channels/508357248330760243/1086122798986051604)
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
!close in preference of <#1086122798986051604 message>
@safe helm
Because your issue seemed to be resolved, this post was marked as resolved by @sonic stratus.
If your issue is not resolved, you can reopen this post by running !reopen.
If you have a different question, make a new post in #1057653400046674112.
this doesnt feel like valid english but w/e