by JJMalina · 2y ago · 0 comments
If you argue that this is not a common problem in practice, then I tend to agree. I haven't seen code with mixed up arguments very much, but when it does happen it can have bad consequences. IMO there is not a big cost to pay to have this extra safety. In TypeScript it's ugly, but in other languages that natively support this typing like Scala, Rust, Swift and Haskell, it works nicely.
Unless you accidentally create the wrong branded type? Which is as likely as disordered arguments.
As you stated, tests should cover this case trivially, I don't see the value in added type complexity.
I would also agree that it's harder to confuse complex types as any single instance of a type is unlikely to overlap once you have a few fields.