Closed lifeart closed 4 years ago
this is interesting!
in flow and hegel (as i know) you can't have interface that primitive types can implement
for example in typescript you can write this
function b<T extends { toString(): string}>(n: T, m: T): string {
return n.toString() + m.toString()
}
void b(1, 1);
describing generic with toString that returns string. so that number can be passed here because typescript does not care about number been primitive and not extending object
but in flow and hegel you can't define interface for primitive types because those are nominally typed flow solves this by typing function by usage but. hegel has a design goal not to do that
probably correct solution would be to allow all values to implement interfaces so typescript style generic can be created
Fixed in 0.0.43
release. Thank you for the contribution ^_^.
ref https://twitter.com/rage_monk/status/1250109296999829504?s=20
input
output: