Skip to content
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

Const objects should *not* be valid weak map keys #33

Closed
dead-claudia opened this issue Jul 2, 2019 · 4 comments
Closed

Const objects should *not* be valid weak map keys #33

dead-claudia opened this issue Jul 2, 2019 · 4 comments

Comments

@dead-claudia
Copy link
Contributor

This can essentially allow people to assign mutable state to an immutable object, and thus it should be disallowed for the same reasons it's not possible to use strings, symbols, numbers, booleans, undefined, or null. It's also consistent with the idea that (const {a: 1}) === (const {a: 1}), despite them being not necessarily physically identical.

@rickbutton
Copy link
Member

Yep! Your reasoning is sound. We illustrated that point in the overview here: https://github.com/rricard/proposal-const-value-types#usage-in-mapsetweakmap

@ljharb
Copy link
Member

ljharb commented Jul 2, 2019

Only objects can be weak; these are primitives.

@rickbutton
Copy link
Member

Yep! @isiahmeadows see the above link for the explainer. I'll go ahead and close this as this is already discussed.

@dead-claudia
Copy link
Contributor Author

Yeah, forgot about it. Sorry for the noise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants