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
Several subtle issues at play here. With #9407 we still perform subtype reduction for the operands of the || and ?: operators. However, even after subtype reduction the expression (''.match(/ /) || []) has type RegExpMatchArray | never[] because there are extra optional properties introduced by RegExpMatchArray. In the property access for the map property we would previously perform subtype reduction again, and that would reduce the union function type of map down to a single type. This step we now omit because of #9407.
I think the real issue here is that we produce the union type RegExpMatchArray | [] instead of just RegExpMatchArray (and this issue was there all along). It may be that for || and ?: we should say that if neither operand is a subtype of the other, but one is assignable to the other, we pick the type of the one to which the other is assignable.
TypeScript Version: master
Code
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: