Created
October 15, 2022 15:19
-
-
Save semlinker/7cc1f7f5cd819dae3ddc470511f4b7c7 to your computer and use it in GitHub Desktop.
TypeName Utility Type
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 TypeName<T> = | |
T extends string ? "string" : | |
T extends number ? "number" : | |
T extends boolean ? "boolean" : | |
T extends undefined ? "undefined" : | |
T extends Function ? "function" : | |
"object"; | |
// "string" | "function" | |
type T10 = TypeName<string | (() => void)>; | |
// "string" | "object" | "undefined" | |
type T11 = TypeName<string | string[] | undefined>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment