Title: "Unique symbol" returned from the function becomes "symbol" · Issue #24506 · microsoft/TypeScript · GitHub
Open Graph Title: "Unique symbol" returned from the function becomes "symbol" · Issue #24506 · microsoft/TypeScript
X Title: "Unique symbol" returned from the function becomes "symbol" · Issue #24506 · microsoft/TypeScript
Description: TypeScript Version: 3.0.0-dev.20180530 Search Terms: unique symbol, property, dynamic class creation Code const create = () => { const prop = Symbol(); return { cls: class A { public [prop]: string = 'str'; // works as expected }, prop, ...
Open Graph Description: TypeScript Version: 3.0.0-dev.20180530 Search Terms: unique symbol, property, dynamic class creation Code const create = () => { const prop = Symbol(); return { cls: class A { public [prop]: string...
X Description: TypeScript Version: 3.0.0-dev.20180530 Search Terms: unique symbol, property, dynamic class creation Code const create = () => { const prop = Symbol(); return { cls: class A { public [prop]: str...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/24506
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Unique symbol\" returned from the function becomes \"symbol\"","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.0.0-dev.20180530\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** \r\nunique symbol, property, dynamic class creation\r\n\r\n**Code**\r\n```ts\r\nconst create = () => { \r\n const prop = Symbol();\r\n\r\n return {\r\n cls: class A {\r\n public [prop]: string = 'str'; // works as expected\r\n },\r\n prop,\r\n };\r\n}\r\n\r\nconst { cls, prop } = create();\r\n\r\nclass B extends cls { \r\n public [prop]: string = 'test'; // Error: 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```\r\n\r\n**Expected behavior:**\r\nNo error.\r\n\r\n**Actual behavior:**\r\nWhen `unique symbol` is returned from function, it becames `symbol` that forbids working with class properties defined inside the function as well as class itself. \r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --> \r\n[Link](http://www.typescriptlang.org/play/#src=const%20create%20%3D%20()%20%3D%3E%20%7B%20%0D%0A%20%20const%20prop%20%3D%20Symbol()%3B%0D%0A%0D%0A%20%20return%20%7B%0D%0A%20%20%20%20cls%3A%20class%20A%20%7B%0D%0A%20%20%20%20%20%20public%20%5Bprop%5D%3A%20string%20%3D%20'str'%3B%0D%0A%20%20%20%20%7D%2C%0D%0A%20%20%20%20prop%2C%0D%0A%20%20%7D%3B%0D%0A%7D%0D%0A%0D%0Aconst%20%7B%20cls%2C%20prop%20%7D%20%3D%20create()%3B%0D%0A%0D%0Aclass%20B%20extends%20cls%20%7B%20%0D%0A%20%20public%20%5Bprop%5D%3A%20string%20%3D%20'test'%3B%0D%0A%7D%0D%0A)\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\nDidn't find any\r\n","author":{"url":"https://github.com/Lodin","@type":"Person","name":"Lodin"},"datePublished":"2018-05-30T22:42:39Z","url":"https://github.com/microsoft/TypeScript/issues/24506"}
| 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:a495f7cf-9918-1cce-77a0-3759bc699047 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2AC:28B6BF:8B5642:C20C0F:6B04820A |
| html-safe-nonce | a78c2cdbf745876ef256d4359780a97080cd4dd38310916e532d481d8e52f58d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkFDOjI4QjZCRjo4QjU2NDI6QzIwQzBGOjZCMDQ4MjBBIiwidmlzaXRvcl9pZCI6Ijg1OTA0OTU5OTMyNjU2ODUwMDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 219263076252674edeabdfcddc7c648825e19ea64f2afda03a676e8fa5853162 |
| hovercard-subject-tag | issue:327925178 |
| 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/24506/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b1c0440db6280570d7ee93dac3217eb0cc1b537c6e2b8569a334249d47035f48/microsoft/TypeScript/issues/24506 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b1c0440db6280570d7ee93dac3217eb0cc1b537c6e2b8569a334249d47035f48/microsoft/TypeScript/issues/24506 |
| og:image:alt | TypeScript Version: 3.0.0-dev.20180530 Search Terms: unique symbol, property, dynamic class creation Code const create = () => { const prop = Symbol(); return { cls: class A { public [prop]: string... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Lodin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0366ddfb372682a32e92a5d86155cb08fa83e5bbe79953a968789f2f7e24c511 |
| 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 | ed3f2e01f6b7672780c586c8af0e72726374d7b6 |
| 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