-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Can't use aliases of the global Symbol
value to refer to its properties in the same manner or create unique symbols
#36468
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
Comments
Global variable reference greatly decreases the performance. https://falsandtru.github.io/benchmark/suites/10/ But we can't avoid this performance problem with Symbol caused by global reference because of this issue. |
I don't quite understand what you're doing or why, or why what you're doing doesn't justify a type assertion |
To improve runtime performance as I explained above.
I'm not sure what you mean. What is meant by "justify a type assertion"? |
@RyanCavanaugh Can you triage the other issues too? |
@falsandtru if you can come cook dinner and tend to my kid I can work evenings |
Symbol
value to refer to its properties in the same manner
@RyanCavanaugh I'm not saying do it right now and the oldest issue in these days (#35896) was opened a month ago. Do you require me to wait more? 2 months? |
@falsandtru your issues are very confusing and require a lot of time to try to piece together what you mean and what you want to happen. You'll have to forgive me that I take up more actionable issues first; other people have put in the work to make understandable reports and are treated as such. |
And can't make unique symbols using an alias of the |
Symbol
value to refer to its properties in the same mannerSymbol
value to refer to its properties in the same manner or create unique symbols
Can you point out where I don't know? It is difficult to know it myself. |
One unfortunate side-effect of the inability to alias the Symbol constructor when defining unique symbol property keys for classes and objects is that it results in increased bundle size, even when compiled with terser (see: terser/terser#1337). Your compiled code becomes littered with Symbol() invocations. Typically in libraries one will alias globals like Math to a local variable to work around terser failing to mangle built-ins, but given this TS limitation there is no way for one to do so. |
The issue in the OP now behaves as desired, so I'm inclined to close this. @bordoley can you confirm or provide a failing repro? |
@RyanCavanaugh: I'll create a test repo, and file a new issue with an example that illustrates the issue. |
Thanks! |
see: #53282 |
Although Nodejs also uses this technique, we can't do the same thing.
https://github.com/nodejs/node/search?q=primordials+symbol&unscoped_q=primordials+symbol
TypeScript Version: 3.7.x-dev.20200125
Search Terms:
Code
Expected behavior:
Actual behavior:
Playground Link: http://www.typescriptlang.org/play/index.html?target=5&ts=3.8.0-dev.20200125&ssl=1&ssc=1&pln=2&pc=21#code/KYDwDg9gTgLgBAbzgXwFAGMIDsDO8DKAngLYBGEANnALxwDmFEpAhhQCoAWAljgHRFlKAbgzY8cHCRpwB5CgAoAlCIDaAXRWzKvLjGBRmMaGqA
Related Issues: #21603 #35478
The text was updated successfully, but these errors were encountered: