Closed
Description
var p = new Array<string>();
var q = true ? p : [];
q[0]
My reasoning follows, please correct me if I'm wrong.
According to 1.5 spec, type of q[0] was calculated in the following way:
- Take union type of
Array<string>
and empty array (Array<Undefined>
). - Reduce that union type, which gives us
Array<string>
, because string is a supertype of undefined. - Widen that type (changes nothing).
- Type of q[0] is string.
According to 1.6 spec, type of q[0] should be calculated in the following way:
- Take union type of
Array<string>
and empty array (Array<Undefined>
). - No reduce is happening.
- Widen that type, resulting in
(Array<string> | Array<any>)
. - Type of q[0] is
(string | any)
.
But that would break "no implicit any". Where did I make a mistake?