Title: esnext features not transpiled within method declarations in object literals with spread elements · Issue #16765 · microsoft/TypeScript · GitHub
Open Graph Title: esnext features not transpiled within method declarations in object literals with spread elements · Issue #16765 · microsoft/TypeScript
X Title: esnext features not transpiled within method declarations in object literals with spread elements · Issue #16765 · microsoft/TypeScript
Description: TypeScript Version: 2.4.0 compilerOptions.target = ES5 Code const obj = {}; const a = { ...obj, prop() { return { ...obj, metadata: 213 } } }; Expected behavior: It compiles and transpiles the object spread operator to a call to Object.a...
Open Graph Description: TypeScript Version: 2.4.0 compilerOptions.target = ES5 Code const obj = {}; const a = { ...obj, prop() { return { ...obj, metadata: 213 } } }; Expected behavior: It compiles and transpiles the obje...
X Description: TypeScript Version: 2.4.0 compilerOptions.target = ES5 Code const obj = {}; const a = { ...obj, prop() { return { ...obj, metadata: 213 } } }; Expected behavior: It compiles and transpiles the obje...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/16765
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"esnext features not transpiled within method declarations in object literals with spread elements","articleBody":"**TypeScript Version:** 2.4.0\r\n\r\ncompilerOptions.target = ES5\r\n\r\n**Code**\r\n\r\n```ts\r\nconst obj = {};\r\nconst a = {\r\n ...obj,\r\n prop() {\r\n return {\r\n ...obj,\r\n metadata: 213\r\n }\r\n }\r\n};\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nIt compiles and transpiles the object spread operator to a call to `Object.assign`.\r\n\r\n**Actual behavior:**\r\n\r\nThe object spread operator is not transpiled but simply kept. This can lead to the following error:\r\n\r\n```\r\n TypeError: Cannot read property 'kind' of undefined\r\n at visitObjectLiteralExpression (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:56775:34)\r\n at visitJavaScript (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:55245:28)\r\n at visitor (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:55182:24)\r\n at visitNode (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:49197:23)\r\n at Object.visitEachChild (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:49479:46)\r\n at visitReturnStatement (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:55345:23)\r\n at visitJavaScript (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:55293:28)\r\n at visitor (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:55182:24)\r\n at Object.visitNodes (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:49248:48)\r\n at transformFunctionBody (C:\\_myplace\\next\\graphql-proxy\\node_modules\\typescript\\lib\\typescript.js:56282:44)\r\n```\r\n\r\nProblem source:\r\n\r\nThe esnext transformer cuts off at method declarations within object literals that have an spread element, thus it never sees the inner object literal node.","author":{"url":"https://github.com/Yogu","@type":"Person","name":"Yogu"},"datePublished":"2017-06-27T13:40:23Z","url":"https://github.com/microsoft/TypeScript/issues/16765"}
| 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:582750e4-0ee4-aa76-b64c-469aaeb7e3c1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7B8:EA09B:7C7EC6:A70F4E:6B00DE7F |
| html-safe-nonce | 77256bea4b01f23270db5ce3d278adcaf398e8695b966f3c2b32f1cf45058985 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0I4OkVBMDlCOjdDN0VDNjpBNzBGNEU6NkIwMERFN0YiLCJ2aXNpdG9yX2lkIjoiODYyMDQxMDE3ODQ4OTA4MTQ3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | da02588ee1de07d869a9f39e7a81304e1eafbb3b8d7d9798dc5fe63379699962 |
| hovercard-subject-tag | issue:238854701 |
| 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/16765/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c8956b42b44a9f317b6319ff96e4fa75f346d02b518e488def155b339ad17039/microsoft/TypeScript/issues/16765 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c8956b42b44a9f317b6319ff96e4fa75f346d02b518e488def155b339ad17039/microsoft/TypeScript/issues/16765 |
| og:image:alt | TypeScript Version: 2.4.0 compilerOptions.target = ES5 Code const obj = {}; const a = { ...obj, prop() { return { ...obj, metadata: 213 } } }; Expected behavior: It compiles and transpiles the obje... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Yogu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width