|
|
|
|
|
by tigershark
2712 days ago
|
|
For example in typescript this is valid: type A = {name: string}
type B = {name: string}
function print(obj: A) { alert(obj.name);}
let a: A = {name: “hello”};
let b: B = {name: “world”}
print(a);
print(b);
This is because of typescript structural equality and I think that the same applies to flow given your link.
Obviously if I want a function to accept an email I don’t want the same function to accept an address, but in typescript you can’t guarantee it because you have no way to get rid of structural equality as far as I understood. |
|
[1] https://medium.com/flow-type/hiding-implementation-details-w...
[2] https://flow.org/en/docs/types/opaque-types/
[3] https://github.com/Microsoft/TypeScript/issues/15807#issueco...