Created
October 17, 2022 04:24
-
-
Save tail-call/0b7711556e67920b2d6fdabc31d77b99 to your computer and use it in GitHub Desktop.
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
interface X { | |
x: any; | |
} | |
interface Y { | |
y: any; | |
} | |
interface Z { | |
z: any; | |
} | |
function f(x: X): Z; | |
function f(y: Y): Z; | |
function f(xOrY: X | Y): Z { | |
if ('x' in xOrY) { | |
return { z: xOrY.x }; | |
} else { | |
return { z: xOrY.y }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment