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
@ahejlsberg The bisect indicates that 25af351 introduced this regression as part of #19671. I think the change is unintentional, in this instance? Before, when we saw RegExpMatchArray on the LHS of || and [any, ""] on the RHS, we did a best-choice thing that eliminated the tuple type from the union (neither is a subtype of the other thanks to tuples and any, I think, but the tuple is assignable to the regexp match array, so was eliminated before). Now that it is preserved, when we go to get the index type for the union, we see a tuple with an any member (created from the shape of the destructuring pattern) and happily state that the numeric index type must thusly be any. I think a decent fix that doesn't revert our behavior back to the best-choice mechanic is to stop using unknownType for positions indicated by OmittedExpressions when building the tuple type in the first place in checkArrayLiteral (since those broaden the index type of the tuple type created to any), and instead use emptyObjectType.
cc @andy-ms
TypeScript Version: 2.7.0-dev.20171223
Code
Expected behavior:
a
is string.Actual behavior:
a
is any.The text was updated successfully, but these errors were encountered: