Title: ES6 Computed Properties · Issue #1082 · microsoft/TypeScript · GitHub
Open Graph Title: ES6 Computed Properties · Issue #1082 · microsoft/TypeScript
X Title: ES6 Computed Properties · Issue #1082 · microsoft/TypeScript
Description: ES6 allows an arbitrary expression as the name of a property. The syntax is like this: var x = { ["some" + "arbitrary" + "name"]: 0 } Here is my current proposal for supporting this feature: Computed expressions would be allowed in the f...
Open Graph Description: ES6 allows an arbitrary expression as the name of a property. The syntax is like this: var x = { ["some" + "arbitrary" + "name"]: 0 } Here is my current proposal for supporting this feature: Comput...
X Description: ES6 allows an arbitrary expression as the name of a property. The syntax is like this: var x = { ["some" + "arbitrary" + "name"]: 0 } Here is my current proposal for s...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/1082
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ES6 Computed Properties","articleBody":"ES6 allows an arbitrary expression as the name of a property. The syntax is like this:\n\n``` ts\nvar x = {\n [\"some\" + \"arbitrary\" + \"name\"]: 0\n}\n```\n\nHere is my current proposal for supporting this feature:\n\nComputed expressions would be allowed in the following places if target is ES6:\n- Object literal properties\n- Class methods and accessors (both static and instance), but not property declarations.\n- 'this' references are not allowed in computed properties.\n- No parameter properties\n- Do not allow in interfaces\n- No enum members\n\nBelow ES6:\n- Computed properties are not allowed\n\nNote that emit for all of the above is straightforward.\n\nType check:\n- All computed names must be of type string, number, or any (or eventually symbol)\n- No property will be added to the containing type based on a computed name.\n- Computed names that are not well known do not add a property to the type, but they will be included in the union type for the indexer, if the containing type has an indexer.\n\nQuestions:\n- Should an unknown name cause the surrounding type to have an indexer, if it wouldn't have acquired one otherwise? Our decision here is 'no'. Here is an argument for and against:\n\nArgument for - we would want this to work:\n\n``` ts\nvar n = \"some \" + \"unknown \" + \"name\";\nvar obj = {\n [n]: 0;\n};\nvar num = obj[n]; // This should be number\n```\n\nArgument against - Computed properties would be allowed in class properties, so someone might have a class hierarchy like this:\n\n``` ts\nvar n = \"some \" + \"unknown \" + \"name\";\nclass C {\n [n]: number;\n}\nclass D extends C {\n foo: string; // Error because C was given an implicit indexer that D inherited, but foo doesn't conform to the indexer\n}\n```\n","author":{"url":"https://github.com/JsonFreeman","@type":"Person","name":"JsonFreeman"},"datePublished":"2014-11-06T23:51:32Z","url":"https://github.com/microsoft/TypeScript/issues/1082"}
| 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:1e71c21c-08e5-f5c5-7179-45a59c47ee95 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3AC:25598F:A5D879:DCF709:6B00EA4E |
| html-safe-nonce | faea84b2e9c830ce14b4b1c3a2e170c7cdba4c33408da628c657675faae3ce06 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0FDOjI1NTk4RjpBNUQ4Nzk6RENGNzA5OjZCMDBFQTRFIiwidmlzaXRvcl9pZCI6Ijg1OTkwMzAyMTM1NDE2ODU4MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a34ab0797b40c3d01db8c488c38b93a4c6c8249f6f94edbbd4d157821b0e03ad |
| hovercard-subject-tag | issue:48030859 |
| 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/1082/issue_layout |
| twitter:image | https://opengraph.githubassets.com/086329afc1ebe1f211f7015ae1930af4127d1d0965ca2781e542db31277b62ae/microsoft/TypeScript/issues/1082 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/086329afc1ebe1f211f7015ae1930af4127d1d0965ca2781e542db31277b62ae/microsoft/TypeScript/issues/1082 |
| og:image:alt | ES6 allows an arbitrary expression as the name of a property. The syntax is like this: var x = { ["some" + "arbitrary" + "name"]: 0 } Here is my current proposal for supporting this feature: Comput... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JsonFreeman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width