Title: ngcc: libraries using spread operator in object literals cannot be processed · Issue #34659 · angular/angular · GitHub
Open Graph Title: ngcc: libraries using spread operator in object literals cannot be processed · Issue #34659 · angular/angular
X Title: ngcc: libraries using spread operator in object literals cannot be processed · Issue #34659 · angular/angular
Description: Consider a library that uses a shared constant for host bindings. e.g. export const BASE_BINDINGS= { '[class.mat-themed]': '_isThemed', } ---- @Directive({ host: {...BASE_BINDINGS, '(click)': '...'} }) export class Dir1 {} @Directive({ h...
Open Graph Description: Consider a library that uses a shared constant for host bindings. e.g. export const BASE_BINDINGS= { '[class.mat-themed]': '_isThemed', } ---- @Directive({ host: {...BASE_BINDINGS, '(click)': '...'...
X Description: Consider a library that uses a shared constant for host bindings. e.g. export const BASE_BINDINGS= { '[class.mat-themed]': '_isThemed', } ---- @Directive({ host: {...BASE_BINDINGS, ...
Opengraph URL: https://github.com/angular/angular/issues/34659
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ngcc: libraries using spread operator in object literals cannot be processed","articleBody":"Consider a library that uses a shared constant for host bindings. e.g.\r\n\r\n```ts\r\nexport const BASE_BINDINGS= {\r\n '[class.mat-themed]': '_isThemed',\r\n}\r\n\r\n----\r\n\r\n@Directive({\r\n host: {...BASE_BINDINGS, '(click)': '...'}\r\n})\r\nexport class Dir1 {}\r\n\r\n@Directive({\r\n host: {...BASE_BINDINGS, '(click)': '...'}\r\n})\r\nexport class Dir2 {}\r\n```\r\n\r\nPreviously when these components were shipped as part of the library to NPM, consumers were able to consume `Dir1` and `Dir2`. No errors showed up.\r\n\r\nNow with Ivy, when ngcc tries to process the library, an error will be thrown. The error is stating that the host bindings should be an object (which they obviously are). This happens because TypeScript transforms the object spread to individual `Object.assign` calls (for compatibility).\r\n\r\nThe partial evaluator used by the `@Directive` annotation handler is unable to process this expression because there is no integrated support for `Object.assign`. In View Engine, this was not a problem because the `metadata.json` files from the library were used to compute the host bindings.\r\n\r\n### Why should Object.assign work?\r\n\r\nCurrently ngtsc works with object spread operators. Just ngcc which runs into the transpiled `Object.assign` calls will not support object spreads. This results in inconsistent behavior.\r\n\r\nAlso, this previously worked in View Engine, so it would help avoiding a breaking change.\r\n\r\n\r\n### How could it be fixed?\r\n\r\nWe could add another `BuiltinFn` into the partial evaluator. It will be somewhat difficult to detect whether a expression with `Object.assign` is actually resolving to the default ES6 `Object.assign`.\r\n\r\nSince the default libs are disabled in the ngcc program, we cannot simply use the type checker. Joost had the idea of providing these types on our own in the program. That would make the detection easy and also work for ES5 files that rely on the `Object.assign` polyfill.","author":{"url":"https://github.com/devversion","@type":"Person","name":"devversion"},"datePublished":"2020-01-07T11:42:20Z","url":"https://github.com/angular/angular/issues/34659"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:818c56df-f45d-50e6-1f71-d8ee8d990aad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF0A:B79B3:44ECF2:5E5514:6AED551F |
| html-safe-nonce | 2a414de6e13e1c796bdac8bbead89a75f2db5bd51f8fa39164235c071d6655bc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjBBOkI3OUIzOjQ0RUNGMjo1RTU1MTQ6NkFFRDU1MUYiLCJ2aXNpdG9yX2lkIjoiMTk3ODMxOTA4NzE2NjM3OTI5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3afefa7074e59e0783f82a7cf7f05714ea5e5a26c43c8839f44f541cf547735d |
| hovercard-subject-tag | issue:546238000 |
| 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/angular/angular/34659/issue_layout |
| twitter:image | https://opengraph.githubassets.com/24df8af2f5cd05ef8eba79514693e24c2aa66214d49f519300b3273823711bb4/angular/angular/issues/34659 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/24df8af2f5cd05ef8eba79514693e24c2aa66214d49f519300b3273823711bb4/angular/angular/issues/34659 |
| og:image:alt | Consider a library that uses a shared constant for host bindings. e.g. export const BASE_BINDINGS= { '[class.mat-themed]': '_isThemed', } ---- @Directive({ host: {...BASE_BINDINGS, '(click)': '...'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devversion |
| hostname | github.com |
| expected-hostname | github.com |
| None | 56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| 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 | 9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width