Skip to content

Instantly share code, notes, and snippets.

@arimariojesus
Last active October 9, 2022 23:17
Show Gist options
  • Save arimariojesus/7fb892df8bf93e673a732b3627b605a1 to your computer and use it in GitHub Desktop.
Save arimariojesus/7fb892df8bf93e673a732b3627b605a1 to your computer and use it in GitHub Desktop.
type DeepReturn<T, K extends string = string> = K extends keyof T
? T[K]
: K extends `${infer TKey}.${infer Rest}`
? TKey extends keyof T
? DeepReturn<Exclude<T[TKey], undefined>, Rest>
: undefined
: undefined;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment