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
export { }
const Symbol = globalThis.Symbol;
const sym = Symbol();
[][Symbol.iterator];
Expected behavior:
const sym = Symbol(); // typeof sym
[][Symbol.iterator]; // Refer iterator method
Actual behavior:
const sym = Symbol(); // symbol
[][Symbol.iterator]; // error
Related Issues: #21603 #35478
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
what 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"?
@RyanCavanaugh Can you triage the other issues too?
@falsandtru if you can come cook dinner and tend to my kid I can work evenings
@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.
Can't use aliases of the global
Symbolvalue to refer to its properties in the same manner
And can't make unique symbols using an alias of the Symbol function. Don't miss it.
your issues are very confusing
Can you point out where I don't know? It is difficult to know it myself.
The聽global Symbol聽properties will聽be聽fixed by聽https://github.com/microsoft/TypeScript/pull/24738, which聽converts聽them all聽to聽unique聽symbol聽types.
Most helpful comment
@falsandtru if you can come cook dinner and tend to my kid I can work evenings