Created
February 17, 2021 14:37
-
-
Save palpich/80d696d0bae7d3e67fd77b5a7cf4594c to your computer and use it in GitHub Desktop.
sdfsdf
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(val: number): typeof add; | |
| function add(): number; | |
| function add(val?: number): number | typeof add { | |
| if (val === undefined) return 0; | |
| let sum = val; | |
| function nextFn(val1: number): typeof nextFn; | |
| function nextFn(): number; | |
| function nextFn(val1?: number): number | typeof nextFn { | |
| if (val1 === undefined) return sum; | |
| sum += val1; | |
| return nextFn; | |
| } | |
| return nextFn; | |
| } | |
| console.log(add()); | |
| console.log(add(1)(2)()); | |
| const bar = add(1)() | |
| const foo = add(1)(2)(2)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment