Comment by saghm
4 days ago
That's because it's structurally typed (as opposed to nominally typed). I don't happen to prefer it, but I don't think it's fair to conflate that with unsoundness like the example given above; it's totally possible to have a sound structural type system. TypeScript doesn't happen to be sound, but it's not because of that.
Structural typing is great. It's the verified version of duck typing.
You can even get nominal typing with branded types if you need it. (Like for the newtype pattern)