by RussianCow · 2y ago · 0 comments
As an example, this syntax should be possible without structural typing or explicitly specifying the type of the value:
// assuming a type signature of moveToPoint(Point)
moveToPoint({x: 5, y: 10}) // the struct literal is inferred to be a Point
I believe F# has syntax like this, but it's been a while since I've used it so I don't remember the details.This may be true, but in reality after 7 years of using TypeScript I don't think I've ever encountered this as a bug for an object (Record) type.
Even for branded types I find the value much more in self-documenting code than actual type safety, and I only have used branded types for primitives.