I'm not sure to properly understand to what extent is Typescript able to narrow types on some cases, and when it can't, how I can help it do so.
I have the following generic that resolves the type of property, matching its nested key.
type PickTypeFromPath<Type, Key> =
Key extends `${infer Head extends keyof Type & string}.${infer Tail}` ? PickTypeFromPath<Type[Head], Tail>
: Key extends keyof Type ? Type[Key]
: never
It works as expected used in standalone, but when I add it as part of a more complex case, (being called from within an other generic), TS does not seem to be able to narrow down the key type, and properly infer the type associated to that property.