-
-
Notifications
You must be signed in to change notification settings - Fork 548
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
Proposal: Opaque #50
Comments
I like it. This sounds like Relevant reading:
Another version:
|
Possible names:
I prefer |
I would be happy to send a PR. All good? |
I'd actually prefer |
My problem with For me, |
Yeah, I'm happy to use that name, since it follows the same concept as my original proposal. |
@BendingBender Yeah, that's a good point. Flow uses I do think that people could just check the README to see what the type means, if they're unsure. |
Oh, didn't know about Swift. As far as I understand it, it's not the same in Swift but also not that different. In Swift it hides the specific type returned from a function. This goes a bit in the same direction. In Haskell, a |
You're right. But what I'm trying to say is that it doesn't tell the user what's the purpose of this new type. |
I don't feel strongly about it and I'm ok with |
Gotcha. I'll send a PR in a bit. Thanks.
On Jul 21, 2019 6:47 PM, Sindre Sorhus <[email protected]> wrote:
I don't feel strongly about it and I'm ok with Opaque too, so we can go for that. PR welcome :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#50?email_source=notifications&email_token=AL42QXB7WMEA4AXM4JOFCY3QASOLXA5CNFSM4IFQEJ7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2OIJLI#issuecomment-513574061>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AL42QXCJHHFM2ENCSTH7FMDQASOLXANCNFSM4IFQEJ7A>.
|
@sindresorhus I've sent the Pull Request. #53 👍 |
Exciting => microsoft/TypeScript#33038 |
@resynth1943 Sorry for bothering, but I think Opaque is unfortunate name for it. The reason is that Opaque by definition hides the internal data structure (that's why it's opaque) so you can't do anything useful with it without the functions that can extract the underlying data from the opaque type. Much like in languages with classes and private fields you can't access or interact with them unless a class will provide a method for it. Current implementation totally allows to get an access to the underlying structure and even focuses on making it easy (via intersection). I'd say Brand is pretty good name cause I've it used for such in various places of TS community. I'm researching the theory and other terms for it. |
@saitonakamura What do you think about the name |
@saitonakamura I'd be interested to hear what you think is a better name for this. I obtained the name "opaque" from Flow, which employs the use of the same name. |
@resynth1943 sorry if it's already clear for you, but for the sake of clarity: the flow
@sindresorhus , @resynth1943 Honestly, I don't have any preference over those three, I mean it's just naming, I think as long as it's not confusing it's fine. But if you'll point a gun at my foot and ask to choose one I'd go for Let me know what option you're ok with, i can submit a PR if you want |
I'm not sure I know enough about this, but I'm confused as to why Typescript ignores the |
@resynth1943 It would be the same for flow actually
|
I don't think it's worth doing a breaking release now, since TS will get support for this anyway, which would eventually make our type moot. |
Ok, thank you for the discussion 🙂 |
I have to say, though, all this is confusing. You would think TypeScript would treat everything the same |
Please add support for opaque types, like so (here's a one liner):
This would then be used like so:
(copied from my gist)
This would be incredibly useful, and the TypeScript developers just don't seem like they're interested in implementing it.
The text was updated successfully, but these errors were encountered: