question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use aliases of the global `Symbol` value to refer to its properties in the same manner or create unique symbols

See original GitHub issue

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

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
falsandtrucommented, Jan 31, 2020

Can’t use aliases of the global Symbol value 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.

2reactions
RyanCavanaughcommented, Jan 31, 2020

@falsandtru if you can come cook dinner and tend to my kid I can work evenings

Read more comments on GitHub >

github_iconTop Results From Across the Web

Symbol - JavaScript - MDN Web Docs
Chrome Edge Symbol Full support. Chrome38. Toggle history Full support. Edge12. footnote... @@toPrimitive Full support. Chrome47. Toggle history Full support. Edge15. Toggle... Symbol() constructor Full support....
Read more >
Symbol Processing (Linker and Libraries Guide)
All global symbols are accumulated internally within the link-editor. Each global symbol supplied by a relocatable object is searched for within this internal ......
Read more >
Details of the policy definition structure - Azure - Microsoft Learn
When a resource property field is an array, a special array alias can be used to select values from all array members and...
Read more >
Introduction to JavaScript “Symbols” and their use in ... - Medium
Two symbols can't have the same value if created from the Symbol() call since every Symbol() call, with or without a description, ...
Read more >
Documentation - Everyday Types - TypeScript
As you might expect, these are the same names you'd see if you used the JavaScript typeof operator on a value of those...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found