| ▲ | clownstrikelol 3 days ago | ||||||||||||||||
That’s barely scratching the surface. In TypeScript the following is also valid: class Something{
}class SomethingElse{
}function AddSomething(v: Something) {
}var ex = new SomethingElse{
};AddSomething(ex); Why does it work? Because in TypeScript as long as you have a “shape” that fits, it’s the “same type.” Complete and utter insanity to me, to pretend there’s any real type checking, when types are entirely fake and made up. | |||||||||||||||||
| ▲ | saghm 3 days ago | parent [-] | ||||||||||||||||
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. | |||||||||||||||||
| |||||||||||||||||