Hacker News new | ask | show | jobs
by saghm 60 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.
1 comments

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)