TypeScript/tests/baselines/reference/TypeGuardWithEnumUnion.types.pull
Cyrus Najmabadi b6d083fa40 Do not publicly expose a way on a Program instance to get typecheckers with differing behavior.
Now, you can only get the non-diagnostics, pull-type-checker from the Program instance.
If you want diagnostics, you simply ask the Program instance for the diagnostics you want.
2015-02-04 16:11:38 -08:00

97 lines
1.7 KiB
Plaintext

=== tests/cases/conformance/expressions/typeGuards/TypeGuardWithEnumUnion.ts ===
enum Color { R, G, B }
>Color : Color
>R : Color
>G : Color
>B : Color
function f1(x: Color | string) {
>f1 : (x: string | Color) => void
>x : string | Color
>Color : Color
if (typeof x === "number") {
>typeof x === "number" : boolean
>typeof x : string
>x : string | Color
var y = x;
>y : Color
>x : Color
var y: Color;
>y : Color
>Color : Color
}
else {
var z = x;
>z : string
>x : string
var z: string;
>z : string
}
}
function f2(x: Color | string | string[]) {
>f2 : (x: string | Color | string[]) => void
>x : string | Color | string[]
>Color : Color
if (typeof x === "object") {
>typeof x === "object" : boolean
>typeof x : string
>x : string | Color | string[]
var y = x;
>y : string[]
>x : string[]
var y: string[];
>y : string[]
}
if (typeof x === "number") {
>typeof x === "number" : boolean
>typeof x : string
>x : string | Color | string[]
var z = x;
>z : Color
>x : Color
var z: Color;
>z : Color
>Color : Color
}
else {
var w = x;
>w : string | string[]
>x : string | string[]
var w: string | string[];
>w : string | string[]
}
if (typeof x === "string") {
>typeof x === "string" : boolean
>typeof x : string
>x : string | Color | string[]
var a = x;
>a : string
>x : string
var a: string;
>a : string
}
else {
var b = x;
>b : Color | string[]
>x : Color | string[]
var b: Color | string[];
>b : Color | string[]
>Color : Color
}
}