Comment

Comment by automatwon

When comparing the types of function parameters, assignment succeeds if either the source parameter is assignable to the target parameter, or vice versa. This is UNSOUND because a caller might end up being given a function that takes a more specialized type, but invokes the function with a less specialized type.

A Google query for the definition of unsound: "not safe or robust"

https://www.typescriptlang.org/docs/handbook/type-compatibil...

You're portraying TypeScript as if it's perfect. Typescript is is permissive and structurally, rather than nominally typed. This is not TypeScript's fault. There will always be tradeoffs. Among other things in the FAQ, there is a section on how to prevent two types from being structurally incompatible. "A possible FIX if you really want two types to be incompatible is to add a 'brand' member"...

https://github.com/Microsoft/TypeScript/wiki/FAQ#type-system...

parent automatwon 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton