Created
March 15, 2021 04:02
-
-
Save mscolnick/73fa6fc26dd11b19c31b96a44a977070 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Unpacked<T> = | |
T extends (infer U)[] ? U : | |
T extends (...args: any[]) => infer U ? U : | |
T extends Promise<infer U> ? U : | |
T; | |
type T0 = Unpacked<string>; // string | |
type T1 = Unpacked<string[]>; // string | |
type T2 = Unpacked<() => string>; // string | |
type T3 = Unpacked<Promise<string>>; // string | |
type T4 = Unpacked<Promise<string>[]>; // Promise<string> | |
type T5 = Unpacked<Unpacked<Promise<string>[]>>; // string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment