Last active
August 23, 2023 03:09
-
-
Save THEtheChad/c5ddf52f97a46d84ae75e9deb9878d33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Narrow<T> = | |
| (T extends Function ? T : never) | |
| (T extends string | number | bigint | boolean ? T : never) | |
| (T extends [] ? [] : never) | |
| { | |
[K in keyof T]: Narrow<T[K]>; | |
}; | |
function narrow<T extends object>(input: Narrow<T>){ | |
return input | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment