Title: Symbols in const assertions should be considered unique · Issue #35562 · microsoft/TypeScript · GitHub
Open Graph Title: Symbols in const assertions should be considered unique · Issue #35562 · microsoft/TypeScript
X Title: Symbols in const assertions should be considered unique · Issue #35562 · microsoft/TypeScript
Description: TypeScript Version: 3.8.0-dev.20191205 Search Terms: const assertion unique symbol "unique symbol" "as const" Code const prop = Symbol() const dictionary = { prop: Symbol() } const sealedDictionary = { prop: Symbol() } as const class MyC...
Open Graph Description: TypeScript Version: 3.8.0-dev.20191205 Search Terms: const assertion unique symbol "unique symbol" "as const" Code const prop = Symbol() const dictionary = { prop: Symbol() } const sealedDictionary...
X Description: TypeScript Version: 3.8.0-dev.20191205 Search Terms: const assertion unique symbol "unique symbol" "as const" Code const prop = Symbol() const dictionary = { prop: Symbol() } co...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/35562
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Symbols in const assertions should be considered unique","articleBody":"**TypeScript Version:** 3.8.0-dev.20191205\r\n\r\n**Search Terms:**\r\n- const assertion unique symbol\r\n- \"unique symbol\" \"as const\"\r\n\r\n**Code**\r\n\r\n```ts\r\nconst prop = Symbol()\r\nconst dictionary = {\r\n prop: Symbol()\r\n}\r\nconst sealedDictionary = {\r\n prop: Symbol()\r\n} as const\r\n\r\nclass MyClass {\r\n // Works because \"prop\" is a unique symbol\r\n [prop]: 1\r\n\r\n // Does not work because \"dictionary.prop\" is not a unique symbol\r\n [dictionary.prop]: 2\r\n\r\n // Does not work because \"sealedDictionary.prop\" is not a unique symbol,\r\n // even though it probably should be?\r\n [sealedDictionary.prop]: 3\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`MyClass` should probably accept `sealedDictionary.prop` as a computed property name since it should be considered a unique symbol.\r\n\r\n**Actual behavior:**\r\n\r\nTypeScript complains with TS1166:\r\n\r\n> A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.\r\n\r\n**Playground Link:** ~[Provided](https://www.typescriptlang.org/play/?target=99&ts=3.8.0-dev.20191205#code/MYewdgzgLgBADgJxHGBeGBlAngWwEYgA2AFAJQCwAUKJLACYCWwUD4AhglmjAN5UzwkcAFyZcBEhUoBfKjWgwIAUzaEldACJMW7Ttz6UBiZKOz4iZKtJhsIMeVCpzCtuwFksAYRcQ7BgQD0ATAA6iAIANZ2eErAbACuyjAARMZwyTAMdmww8WAMAI7xSoriRPwwANppALqiAIxOhjBBMBogSnZgILAA7uERMDFxiSXJjMysYBxYAHRpGVkw3bA5eYXFpeaEFZUTOtOc80J1MABMTYHB7Z3LPTD9kUOxCUnJyqrqWpO6cwuZXXua3yRRKEDKhAANBVWkoAG5KMAwKAACxA8QA5ijMrBjHg2HhCFwIGj4oQ6M8APy7D5qTTaKYzY7IU4AZisQA)~ [Updated](https://www.typescriptlang.org/play?ts=3.8.2#code/MYewdgzgLgBADgJxHGBeGBlAngWwEYgA2AFAJQCwAUKJLACYCWwUD4AhglmjAN5UzwkcAFyZcBEhUoBfKjWgwIAUzaEldACJMW7Ttz6UBiZKOz4iZKtJhsIMeVCpzCtuwFksAYRcQ7BgQD0ATAA6iAIANZ2eErAbACuyjAARMZwyTAMdmww8WAMAI7xSoriRPwwANppALqiAIxOhjBBMBogSnZgILAA7uERMDFxiSXJjMysYBxYAHRpGVkw3bA5eYXFpeaEFZUTOtOc80J1MABMTYHB7Z3LPTD9kUOxCUnJyqrqWpO6cwuZXXua3yRRKEDKhAANBVWkoAG5KMAwKAACxA8QA5ijMrBjHg2HhCFwIGj4oQ6M8APy7D5qTTaKYzY7IU4AZisQA) (old link seems to be broken in new playground)\r\n\r\n**Related Issues:** —\r\n","author":{"url":"https://github.com/loilo","@type":"Person","name":"loilo"},"datePublished":"2019-12-07T00:25:30Z","url":"https://github.com/microsoft/TypeScript/issues/35562"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0d6afd47-be24-843f-cc33-608554a485cd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEC0:46A3B:6E43EB:96D37C:6B047808 |
| html-safe-nonce | dea72ee5f546071a839533b43cc7418a406e2547f08506df9223dbd2d55e4e1d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRUMwOjQ2QTNCOjZFNDNFQjo5NkQzN0M6NkIwNDc4MDgiLCJ2aXNpdG9yX2lkIjoiMzAwMTkxNTc1OTIzNzgyMjQ3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 45aa542cabf203498cf1671125fe4b391d934905859799829e928a33349c97e7 |
| hovercard-subject-tag | issue:534319905 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/35562/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1176cb8017bee9ee2e44847dcdf17c567defcd4f88d5fe49372b5a2518737ae3/microsoft/TypeScript/issues/35562 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1176cb8017bee9ee2e44847dcdf17c567defcd4f88d5fe49372b5a2518737ae3/microsoft/TypeScript/issues/35562 |
| og:image:alt | TypeScript Version: 3.8.0-dev.20191205 Search Terms: const assertion unique symbol "unique symbol" "as const" Code const prop = Symbol() const dictionary = { prop: Symbol() } const sealedDictionary... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | loilo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cf73f57448d52b3a7b619195e182b33d3b3454ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width