Skip to content

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

Closed
@falsandtru

Description

@falsandtru

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions