Title: Object spread incorrectly compiles getter · Issue #24799 · microsoft/TypeScript · GitHub
Open Graph Title: Object spread incorrectly compiles getter · Issue #24799 · microsoft/TypeScript
X Title: Object spread incorrectly compiles getter · Issue #24799 · microsoft/TypeScript
Description: TypeScript Version: 2.9.1 Search Terms: object spread getter Code const A = { a: 1 }; const X = { ...A, get x() { return this.a } }; const Y = { a: A.a, get x() { return this.a } }; console.log(X.x, Y.x) Expected behavior: 1 1 Actual beh...
Open Graph Description: TypeScript Version: 2.9.1 Search Terms: object spread getter Code const A = { a: 1 }; const X = { ...A, get x() { return this.a } }; const Y = { a: A.a, get x() { return this.a } }; console.log(X.x...
X Description: TypeScript Version: 2.9.1 Search Terms: object spread getter Code const A = { a: 1 }; const X = { ...A, get x() { return this.a } }; const Y = { a: A.a, get x() { return this.a } }; console.log(X.x...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/24799
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Object spread incorrectly compiles getter","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:** 2.9.1\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\nobject spread getter\r\n\r\n**Code**\r\n\r\n```ts\r\nconst A = { a: 1 };\r\nconst X = { ...A, get x() { return this.a } };\r\nconst Y = { a: A.a, get x() { return this.a } };\r\nconsole.log(X.x, Y.x)\r\n```\r\n\r\n**Expected behavior:**\r\n1 1\r\n\r\n**Actual behavior:**\r\nundefined 1\r\n\r\nThe [proposal](https://github.com/tc39/proposal-object-rest-spread/blob/master/Spread.md) says that ``get x()`` should not be called (section *Getters on the Object Initializer*).\r\n\r\nExecuting the code in Chrome (66) console produces the expected behavior.\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --> \r\n[link](https://www.typescriptlang.org/play/index.html#src=const%20A%20%3D%20%7B%20a%3A%201%20%7D%3B%0D%0Aconst%20X%20%3D%20%7B%20...A%2C%20get%20x()%20%7B%20return%20this.a%20%7D%20%7D%3B%0D%0Aconst%20Y%20%3D%20%7B%20a%3A%20A.a%2C%20get%20x()%20%7B%20return%20this.a%20%7D%20%7D%3B%0D%0Aconsole.log(X.x%2C%20Y.x)%3B)\r\n","author":{"url":"https://github.com/dsehnal","@type":"Person","name":"dsehnal"},"datePublished":"2018-06-08T16:17:06Z","url":"https://github.com/microsoft/TypeScript/issues/24799"}
| 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:ba3496a4-cb86-5e6d-92f6-d5a6fa926556 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D43A:E9D16:231A053:2C85553:6B01B6BF |
| html-safe-nonce | 09a1ac6bfa52827cbde8734368379762130bea0e98d112a01f2a23414f5858f8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDNBOkU5RDE2OjIzMUEwNTM6MkM4NTU1Mzo2QjAxQjZCRiIsInZpc2l0b3JfaWQiOiI3OTczNDI5ODUwMzI0MTQ5MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 615c0ab19487c2335cb358f62d1b45892210c07f47a15174dedca229b3fd158f |
| hovercard-subject-tag | issue:330720686 |
| 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/24799/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1c9608e234c2a57d3352711a1441e25e68d5d55f661ddf979772011d45ef9c77/microsoft/TypeScript/issues/24799 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1c9608e234c2a57d3352711a1441e25e68d5d55f661ddf979772011d45ef9c77/microsoft/TypeScript/issues/24799 |
| og:image:alt | TypeScript Version: 2.9.1 Search Terms: object spread getter Code const A = { a: 1 }; const X = { ...A, get x() { return this.a } }; const Y = { a: A.a, get x() { return this.a } }; console.log(X.x... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dsehnal |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width