-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Symbols in const assertions should be considered unique #35562
Comments
It seems that symbols lose their "unique" when assigned to an object. Another example of this behaviour: Playground. |
@RyanCavanaugh you marked this as "awaiting more feedback". Can you elaborate on what that means? Is it community feedback or maintainer feedback you are looking for? I ran into this problem the other and was convinced for a while that it was an issue with typescripts symbol index support, until I was pointed here. It would be really nice if this was fixed. |
Is the current behaviour intentional or an oversight? It's frustrating that to create an object of unique symbols you have to do this: const a = Symbol();
const b = Symbol();
const symbols = { a, b } as const; It would be nicer if you could declare the symbols directly: const symbols = {
a: Symbol(),
b: Symbol()
} as const; |
Any updates? |
It is very inconvenient to write such code now. I have to do this: const fooSymbols = {
a: Symbol(),
b: Symbol()
} as {
readonly a: unique symbol
readonly b: unique symbol
} But there are indeed some things to consider about this issue, such as const _b = Symbol()
const fooSymbols = {
get a() {
return Symbol()
},
get b() {
return _b
}
} as const Is it possible to not process the properties corresponding to |
TypeScript Version: 3.8.0-dev.20191205
Search Terms:
Code
Expected behavior:
MyClass
should probably acceptsealedDictionary.prop
as a computed property name since it should be considered a unique symbol.Actual behavior:
TypeScript complains with TS1166:
Playground Link:
ProvidedUpdated (old link seems to be broken in new playground)Related Issues: —
The text was updated successfully, but these errors were encountered: