Open danvk opened 9 years ago
(I'm using flow 0.8.0)
From IRC:
glevi: danvk: So number is a subtype of (number | string) and string is a subtype of (number | string)
glevi: danvk: However (number | string) is also a subtype of (number | string )
and if T=number|string
, then T < T
is possibly invalid.
Creating a Comparable
marker type would be an acceptable solution. So would allowing an OR of types, e.g. T=number
or T=string
, but not T=number|string
.
This code:
produces the following error:
In most type systems, the
T
inother: Foo<T>
would be the sameT
as for the current class. This would result in number↔number and string↔string comparisons, but never number↔string.Removing the
<T>
inother: Foo<T>
makes the error go away, but now I have no confidence that Flow is actually checking anything.