Quantcast
Channel: User bdsl - Stack Overflow
Viewing all articles
Browse latest Browse all 38

Comment by bdsl on Is there an elegant way to have value objects in typescript?

$
0
0
And I see that this works even if I create another class LegalName with the same shape but a different validation rule - e.g. perhaps a LegalName has to contain a space. If I try to use one in place of the other I get a compile error: "Type 'UserName' is not assignable to type 'LegalName'. Types have separate declarations of a private property 'compute'" Looks like it's effectively doing nominal typing, which I'm liking.

Viewing all articles
Browse latest Browse all 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>