Created
February 11, 2024 12:00
-
-
Save turbod/45e207695e069881390b6e376776971f 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
function add(a: number, b: number): number { | |
return a + b; | |
} | |
type Test = typeof add; | |
// ^ = type Test = (a: number, b: number) => number | |
type Test2 = ReturnType<typeof add>; | |
// ^ = type Test2 = number | |
// | |
type MyReturnType<T> = T extends (...args: any[]) => infer R ? R : any; | |
type Test3 = MyReturnType<typeof add>; | |
// ^ = type Test3 = number | |
// | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment