New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the Opaque
type stricter
#71
Make the Opaque
type stricter
#71
Conversation
This commit adds a Token parameter to the Opaque types, allowing them to be fundamentally unique. This means an oaque type cannot be cast to a separate opaque type. The previous (flawed) design allowed this. This does not.
Should I |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should also add an explicit test that they are really opaque, i.e., add a test that resembles the first post of the issue
The thing is, I believe my test resembles the first post of the issue well. It shows opaque types are not interchangeable, which is the desired effect. |
Because TypeScript supports recursive types, the type Person = {
id: Opaque<number, Person>;
name: string;
}; |
@sindresorhus Yes! 😛 I'll add something like that into the TSDoc block. Thanks. |
Damn. We gotta get this merged. |
/bing @sindresorhus @papb |
Also, I'd like to give apologies for my absence. I've currently been doing my mock examinations in school. Anyway, that's over now, and I'm back. 😛 |
Opaque
type stricter
Thanks :) |
This commit adds a Token parameter to the Opaque types, allowing them to be
fundamentally unique. This means an oaque type cannot be cast to a separate
opaque type. The previous (flawed) design allowed this. This does not.
Closes #70.