You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
I did search to see if I could find the answer but no luck.
The question is simple, is this supposed to work? Because it should with babel as it stands, if it does then it should be noted somewhere more obvious.
classTest{
#foo='bar';/** * @param {Test} t */staticbaz(t){t.#foo='baz';}getfoo(){returnthis.#foo;}}constt=newTest();console.info(t.foo);// prints 'bar'Test.baz(t);console.info(t.foo);// prints 'baz'
The text was updated successfully, but these errors were encountered:
@littledan cases like this should definitely be called out.
Thank you. It was a surprise to see it working, but (from previous experience) I didn't want to rely on undocumented behaviour with anything not in stage 4.
@rijnhard Can I ask why it was a surprise to see it working?
@bakkot Honestly, because I didn't expect it to have access to the context. I use WeakMaps and WeakSets quite a bit, and usually in cases where I want to create a private scope. (If I want anything other than fully private I abuse Object.defineProperty). From skimming the docs and comments I saw the implementation was based on WeakSets. Added to that I know that private variables are private, not protected, so no access from child classes, and for some reason, in my mind, I equated prototype methods to being in a different scope.
tl;dr I didn't think prototype methods could have access because of guesses I made from half of the info I read about implementation.
So I just knew enough to make a bad guess, lol.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The question is simple, is this supposed to work? Because it should with babel as it stands, if it does then it should be noted somewhere more obvious.
The text was updated successfully, but these errors were encountered: