Repository navigation
Can't use aliases of the global Symbol value to refer to its properties in the same manner or create unique symbols #36468
Description
Activity
falsandtru commented
on Jan 28, 2020 ContributorAuthorMore actionsGlobal 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.
Reacted by ExE Boss- addedNeeds More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified
on Jan 29, 2020 RyanCavanaugh commented
on Jan 29, 2020 MemberMore actionsI don't quite understand what you're doing or why, or why what you're doing doesn't justify a type assertion
falsandtru commented
on Jan 29, 2020 ContributorAuthorMore actionswhat you're doing or why
To improve runtime performance as I explained above.
why what you're doing doesn't justify a type assertion
I'm not sure what you mean. What is meant by "justify a type assertion"?
falsandtru commented
on Jan 31, 2020 ContributorAuthorMore actionsRyan Cavanaugh (@RyanCavanaugh) Can you triage the other issues too?
RyanCavanaugh commented
on Jan 31, 2020 MemberMore actionsfalsandtru (@falsandtru) if you can come cook dinner and tend to my kid I can work evenings
Reacted by AnyhowStep, Bruce Pascoe and Rui- addedAwaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScriptand removedNeeds More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified
on Jan 31, 2020 - changed the title
[-]Aliased Symbol doesn't work[/-][+]Can't use aliases of the global `Symbol` value to refer to its properties in the same manner[/+]on Jan 31, 2020 falsandtru commented
on Jan 31, 2020 ContributorAuthorMore actionsRyan Cavanaugh (@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?
RyanCavanaugh commented
on Jan 31, 2020 MemberMore actionsfalsandtru (@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.
falsandtru commented
on Jan 31, 2020 ContributorAuthorMore actionsCan't use aliases of the global
Symbolvalue to refer to its properties in the same mannerAnd can't make unique symbols using an alias of the
Symbolfunction. Don't miss it.Reacted by Ryan Cavanaugh and ExE Boss- changed the title
[-]Can't use aliases of the global `Symbol` value to refer to its properties in the same manner[/-][+]Can't use aliases of the global `Symbol` value to refer to its properties in the same manner or create unique symbols[/+]on Jan 31, 2020 falsandtru commented
on Jan 31, 2020 ContributorAuthorMore actionsyour issues are very confusing
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.
Reacted by ExE BossRyanCavanaugh commented
on Mar 15, 2023 MemberMore actionsThe issue in the OP now behaves as desired, so I'm inclined to close this. Dave (@bordoley) can you confirm or provide a failing repro?
Ryan Cavanaugh (@RyanCavanaugh): I'll create a test repo, and file a new issue with an example that illustrates the issue.
RyanCavanaugh commented
on Mar 15, 2023 MemberMore actionsThanks!
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