You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declarevarx: {type: "A",value: number;}|{type: "B",value: string;};if(x.type==="A"){x.value;// Correctly inferred to be number}declarevary: ["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.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.2.1
Code
Expected behavior:
y[1]
should be inferred as a number based on the value ofy[0]
Actual behavior:
y[1]
is inferred to bestring|number
.The text was updated successfully, but these errors were encountered: