Created
December 24, 2021 19:41
-
-
Save snoble/e82bdf1212792febb16cf64d92152929 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
type T = {x: string, y: string} | {a:string, b: string} | |
function fn(a: T) { | |
if('x' in a) { | |
return a.y | |
} else { | |
return a.b | |
} | |
} | |
console.log(fn({x: 'xx', a: 'aa', b: 'bb'})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment