Created
December 14, 2021 01:04
-
-
Save akaptur/742fcba884c0fec83983b73f642a3252 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 A = { | |
value: string; | |
kind: "a"; // here's the tag | |
}; | |
type B = { | |
value: string; | |
kind: "b"; | |
}; | |
function my_func(a: A): string { | |
return a.value; | |
} | |
my_func({value: "hi", kind: "a"}); // no error, unsurprisingly | |
my_func({value: "hi", kind: "b"}); // now this *is* an error | |
my_func({value: "hi"}); // also an error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment