Title: feat: Allow using ancestor decorator values to declare descendant decorators · Issue #13764 · angular/angular · GitHub
Open Graph Title: feat: Allow using ancestor decorator values to declare descendant decorators · Issue #13764 · angular/angular
X Title: feat: Allow using ancestor decorator values to declare descendant decorators · Issue #13764 · angular/angular
Description: I'm submitting a ... (check one with "x") [x] feature request Problem When specifying a decorator on a component, the descendant decorator overrides the ancestor decorator. This become problematic if the descendant class wants to modify ...
Open Graph Description: I'm submitting a ... (check one with "x") [x] feature request Problem When specifying a decorator on a component, the descendant decorator overrides the ancestor decorator. This become problematic ...
X Description: I'm submitting a ... (check one with "x") [x] feature request Problem When specifying a decorator on a component, the descendant decorator overrides the ancestor decorator. This becom...
Opengraph URL: https://github.com/angular/angular/issues/13764
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat: Allow using ancestor decorator values to declare descendant decorators","articleBody":"**I'm submitting a ...** (check one with \"x\")\r\n```\r\n[x] feature request\r\n```\r\n\r\n**Problem**\r\n\r\nWhen specifying a decorator on a component, the descendant decorator overrides the ancestor decorator. This become problematic if the descendant class wants to modify a value that can only be supplied in the `@Component` decorator. The only solution, currently, is to snap-shot the ancestor values. Snap shots are a maintenance issues because:\r\n\r\n1. If the ancestor values are ever changed as all descendants need to be updated. \r\n2. Updating all descendant classes is impossible if the component is in a re-usable library as the library author might not have access to all descendants.\r\n3. It is unclear what the descendant meant to override and what it intended to copy so updating descendant classes is dangerous.\r\n\r\n**Proposal**\r\n\r\nInclude a special value called `inherited` that is usable when specifying decorators that allows referencing value from the decorate of the ancestor. `inherited` would be substitutable for any value in decorator and is substituted, during template code generation, for the ancestor decorator field value for the corresponding field.\r\n\r\nThe `inherited` value can be used with object spread syntax to mean include all the ancestor properties with the inherited values. This would be equivalent to specifying all decorator values as `inherited`.\r\n\r\n`inherited` would also be allowed in `providers` arrays which is substituted with the ancestor's `providers` array.\r\n\r\n**Example**\r\n\r\n```ts\r\n@Component({\r\n stylesUrl: './base_styles.css',\r\n providers: [BASE_PROVIDERS]\r\n})\r\nclass BaseComponent {\r\n}\r\n\r\n\r\n@Component({\r\n ...inherited,\r\n providers: [inherited, { provider: SomeToken, useValue: someValue} ],\r\n template: `some template`\r\n})\r\nclass MyComponent extends BaseComponent {\r\n\r\n}\r\n```\r\n\r\n**Limitations**\r\n\r\nBecause the value is not substituted immediately, the value cannot be used in calculations that would otherwise be supported. For example, the following will not be supported:\r\n\r\n```ts\r\n@Component({\r\n ...inherited,\r\n template: inherited + `additional elements` // NOT SUPPORTED\r\n})\r\nclass Unsupported extends BaseClass {\r\n}\r\n```\r\n\r\nThe above would result in a type error in TypeScript and undefined behavior in ES6. This scenario would need to use an exported constant value that is supported without feature such as,\r\n\r\n```ts\r\n@Component({\r\n ...inherited,\r\n template: BASECLASS_TEMPLATE + `additional elements` // NOT SUPPORTED\r\n})\r\nclass Unsupported extends BaseClass {\r\n}\r\n```\r\n\r\nwhere `BASECLASS_TEMPLATE` is exported from the base class' module.\r\n","author":{"url":"https://github.com/chuckjaz","@type":"Person","name":"chuckjaz"},"datePublished":"2017-01-03T23:31:48Z","url":"https://github.com/angular/angular/issues/13764"}
| 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:1b0eedab-a04e-7666-dc24-f0fce749f5bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D586:3F8AB1:ABE653:DE3FB1:6B00E4AA |
| html-safe-nonce | 45bb9a5feab7db61612b89985daa8687c59dfd637259be4bc0b04c3ea40e5a25 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTg2OjNGOEFCMTpBQkU2NTM6REUzRkIxOjZCMDBFNEFBIiwidmlzaXRvcl9pZCI6IjY3NzA5NTcyNDc4OTMyNzAxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5467476f3b4e62c485c0a82503dc0cbb86bd84124d0f0d32c1f4b64a7b01b160 |
| hovercard-subject-tag | issue:198596231 |
| 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/13764/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a3366d69a91b361f904206602b721915e02f728e865b6f572ca7600877ada142/angular/angular/issues/13764 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a3366d69a91b361f904206602b721915e02f728e865b6f572ca7600877ada142/angular/angular/issues/13764 |
| og:image:alt | I'm submitting a ... (check one with "x") [x] feature request Problem When specifying a decorator on a component, the descendant decorator overrides the ancestor decorator. This become problematic ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chuckjaz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width