Created
December 14, 2018 19:39
-
-
Save fahrradflucht/b38ee5bd1b281281e9ab960d6b875713 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 ArgumentsType<T> = T extends (...args: infer A) => unknown ? A : never; | |
const add = (a: number, b: number): number => a + b | |
type Add = typeof add; | |
function logAdd(...args: ArgumentsType<Add>): ReturnType<Add> { | |
const [a, b] = args; | |
const result = add(a, b) | |
console.log(a, b, result) | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReturnType<T>
is a predefined conditional type.