Title: Spread operator does not call property getters · Issue #26547 · microsoft/TypeScript · GitHub
Open Graph Title: Spread operator does not call property getters · Issue #26547 · microsoft/TypeScript
X Title: Spread operator does not call property getters · Issue #26547 · microsoft/TypeScript
Description: Search Terms: spread operator, property getter Code interface IWhatever { readonly value: number; } class Whatever implements IWhatever { public get value() { return 42; } } const whatever: IWhatever = new Whatever(); const obj = { ...wh...
Open Graph Description: Search Terms: spread operator, property getter Code interface IWhatever { readonly value: number; } class Whatever implements IWhatever { public get value() { return 42; } } const whatever: IWhatev...
X Description: Search Terms: spread operator, property getter Code interface IWhatever { readonly value: number; } class Whatever implements IWhatever { public get value() { return 42; } } const whatever: IWhatev...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/26547
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spread operator does not call property getters","articleBody":"**Search Terms:**\r\nspread operator, property getter\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface IWhatever {\r\n readonly value: number;\r\n}\r\n\r\nclass Whatever implements IWhatever {\r\n public get value() {\r\n return 42;\r\n }\r\n}\r\n\r\nconst whatever: IWhatever = new Whatever();\r\nconst obj = { ...whatever, otherValue: 43 };\r\nconsole.log(obj);\r\n```\r\n\r\n**Expected behavior:**\r\n{ value: 42, otherValue: 43 }\r\n\r\nThis is expected because a readonly property of an interface can be implemented with a getter. The code using the interface cannot know that the property is implemented with a getter and therefore expects to see the property of the interface in the result. \r\n\r\n**Actual behavior:**\r\n{ otherValue: 43 }\r\n\r\n**Playground Link:**\r\n[Link](https://www.typescriptlang.org/play/#src=interface%20IWhatever%20%7B%0D%0A%20%20%20%20readonly%20value%3A%20number%3B%0D%0A%7D%0D%0A%0D%0Aclass%20Whatever%20implements%20IWhatever%20%7B%0D%0A%20%20%20%20public%20get%20value()%20%7B%0D%0A%20%20%20%20%20%20%20%20return%2042%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0Aconst%20whatever%3A%20IWhatever%20%3D%20new%20Whatever()%3B%0D%0Aconst%20obj%20%3D%20%7B%20...whatever%2C%20otherValue%3A%2043%20%7D%3B%0D%0Aconsole.log(obj)%3B%0D%0A)\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/andreashuber69","@type":"Person","name":"andreashuber69"},"datePublished":"2018-08-20T12:10:41Z","url":"https://github.com/microsoft/TypeScript/issues/26547"}
| 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:5927592a-ac16-f35e-fa73-8ecbe56537e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2B8:215B92:2743066:344F5E3:6B01AD3A |
| html-safe-nonce | a1dc81c7c766bb61b64b185fcce1484a5d0338abf5cab9d17a1c1d0a8aa1c341 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkI4OjIxNUI5MjoyNzQzMDY2OjM0NEY1RTM6NkIwMUFEM0EiLCJ2aXNpdG9yX2lkIjoiNzUyMTU4MTAxNjcyMTUwMTQ5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 897efd72d69c64e9c5d240aefb6ef47a72aefd579ffd6fff8df0023b44c9e9f1 |
| hovercard-subject-tag | issue:352107530 |
| 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/26547/issue_layout |
| twitter:image | https://opengraph.githubassets.com/94694b810857777a8c38d534983dc3a43f3adf2e070e0708805a37212a9c6462/microsoft/TypeScript/issues/26547 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/94694b810857777a8c38d534983dc3a43f3adf2e070e0708805a37212a9c6462/microsoft/TypeScript/issues/26547 |
| og:image:alt | Search Terms: spread operator, property getter Code interface IWhatever { readonly value: number; } class Whatever implements IWhatever { public get value() { return 42; } } const whatever: IWhatev... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andreashuber69 |
| 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