Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
gmdrd
on April 26, 2024
|
parent
|
context
|
favorite
| on:
TypeScript: Branded Types
Is there something wrong with creating opaque types using this method?
type ObjectId = string & { readonly __tag: unique symbol }
This way, we don't need to use `never`, but we still prevent the creation of a structurally equivalent type by mistake.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: