Closed
Description
TypeScript Version: 2.2.1
Code
declare var x: { type: "A", value: number; } | { type: "B", value: string; };
if (x.type === "A") {
x.value; // Correctly inferred to be number
}
declare var y: ["A", number] | ["B", string];
if (y[0] === "A") {
y[1]; // Not inferred as number but as string | number
}
Expected behavior: y[1]
should be inferred as a number based on the value of y[0]
Actual behavior: y[1]
is inferred to be string|number
.