Better HN
topnewbestaskshowjobs
Log inSign up

joakimbeng

1 karma · joined Oct 15, 2023 (3y ago) · 1 submissions

Submissions

comment 3y ago · link · parent

For such problems we use the Opaque type from the nifty type-fest package. We use it for all of our id types (which are usually numbers) so we can't accidentally mix them.

In your example it would be:

    type Age = Opaque<number, "Age">
And then you wouldn't be able to pass a random number to printAge