1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes02.ts ===
type T = string | "foo" | "bar" | "baz";
>T : string
var x: "foo" | "bar" | "baz" | string = undefined;
>x : string
>undefined : undefined
var y: T = undefined;
>y : string
>undefined : undefined
if (x === "foo") {
>x === "foo" : boolean
>x : string
>"foo" : "foo"
let a = x;
>a : string
>x : "foo"
}
else if (x !== "bar") {
>x !== "bar" : boolean
>x : string
>"bar" : "bar"
let b = x || y;
>b : string
>x || y : string
>x : string
>y : string
}
else {
let c = x;
>c : string
>x : "bar"
let d = y;
>d : string
>y : string
let e: (typeof x) | (typeof y) = c || d;
>e : string
>x : "bar"
>y : string
>c || d : string
>c : string
>d : string
}
x = y;
>x = y : string
>x : string
>y : string
y = x;
>y = x : string
>y : string
>x : string
|