Created
February 25, 2016 00:54
-
-
Save dmitry-a-morozov/47ce5ca63541085258f5 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
class C1 { item: string } | |
class C2 { item: string[] } | |
class C3 { item: string } | |
type C1_C2_C3 = C1 | C2 | C3; | |
function Foo(x: C1_C2_C3): string { | |
if (x instanceof C1) return x.item; | |
else if (x instanceof C2) return x.item[0]; | |
else if (x instanceof C3) return x.item; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment