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
Inferred type of v2 is Array<(any | number)>, and of sum is any | number. One would think the inferred types should instead be Array<(number)> and number respectively.
eidheim
changed the title
Inconsistent inferred types when using array methods map() and filter()
Inconsistent inferred types when using array methods map() and reduce()
Oct 4, 2019
This is still an issue in v0.132.0. v2 is Array<number> at the time it is born and adding a piece of code that uses it afterwards turns it to a looser type Array<any | number>, which is quite unexpected.
From:
Inferred type of
v2
isArray<(any | number)>
, and ofsum
isany | number
. One would think the inferred types should instead beArray<(number)>
andnumber
respectively.The above behaviour was introduced in Flow v0.86.
However, the following code infers correct types:
That is, the inferred types of
v2
andsum
areArray<number>
andnumber
.Flow version: v0.86-v0.108
Expected behavior
Consistent inferred types of
v2
andsum
in the above examples.Actual behavior
Inconsistent inferred types of
v2
andsum
in the above examples.Try-Flow
The text was updated successfully, but these errors were encountered: