Title: property decorators break at runtime with ES2015 and circular deps · Issue #30141 · angular/angular · GitHub
Open Graph Title: property decorators break at runtime with ES2015 and circular deps · Issue #30141 · angular/angular
X Title: property decorators break at runtime with ES2015 and circular deps · Issue #30141 · angular/angular
Description: 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? No Description Using the `@Input()` property decorator (or any other property decorators I imagine) targetting ES2015 with a circular depend...
Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? No Description Using the `@Input()` property decorator (or any other property decorators I imagine) ...
X Description: 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? No Description Using the `@Input()` property decorator (or any other property decorators I imagine) ...
Opengraph URL: https://github.com/angular/angular/issues/30141
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"property decorators break at runtime with ES2015 and circular deps","articleBody":"\u003c!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅\r\n\r\nOh hi there! 😄\r\n\r\nTo expedite issue processing please search open and closed issues before submitting a new one.\r\nExisting issues often contain information about workarounds, resolution, or progress updates.\r\n\r\n🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->\r\n\r\n\r\n# 🐞 bug report\r\n\r\n### Affected Package\r\n\u003c!-- Can you pin-point one or more @angular/* packages as the source of the bug? -->\r\n\u003c!-- ✍️edit: --> The issue is caused by package @angular/core\r\n\r\n\r\n### Is this a regression?\r\n\r\n\u003c!-- Did this behavior use to work in the previous version? -->\r\n\u003c!-- ✍️--> No\r\n\r\n\r\n### Description\r\n\r\n\u003c!-- ✍️--> Using the `@Input()` property decorator (or any other property decorators I imagine) targetting ES2015 with a circular dependency on a type will cause a `Uncaught ReferenceError` at runtime.\r\n\r\n\r\n## 🔬 Minimal Reproduction\r\n```\r\ngit clone https://github.com/filipesilva/istiti-circular-deps-es2015\r\ncd istiti-circular-deps-es2015\r\nng serve\r\n# src/app/autocomplete.directive.ts contains the problematic decorator and circular dep\r\n```\r\n\r\n## 🔥 Exception or Error\r\n\u003cpre>\u003ccode>\r\nmain.js:9545 Uncaught ReferenceError: Cannot access 'AutocompleteAbstract' before initialization\r\n at Module.AutocompleteAbstract (main.js:9545)\r\n at Module../src/app/autocomplete.directive.ts (main.js:9580)\r\n at __webpack_require__ (runtime.js:79)\r\n at Module../src/app/autocomplete.abstract.ts (main.js:9546)\r\n at __webpack_require__ (runtime.js:79)\r\n at Module../src/app/parent.component.ts (main.js:9605)\r\n at __webpack_require__ (runtime.js:79)\r\n at Module../src/app/app.module.ts (main.js:9507)\r\n at __webpack_require__ (runtime.js:79)\r\n at Module../src/main.ts (main.js:9666)\r\n\u003c/code>\u003c/pre>\r\n\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\nAngular CLI: 8.0.0-beta.16\r\nNode: 10.10.0\r\nOS: win32 x64\r\nAngular: 8.0.0-beta.13\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... language-service, platform-browser, platform-browser-dynamic\r\n... router\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.800.0-beta.16\r\n@angular-devkit/build-angular 0.800.0-beta.16\r\n@angular-devkit/build-optimizer 0.800.0-beta.16\r\n@angular-devkit/build-webpack 0.800.0-beta.16\r\n@angular-devkit/core 8.0.0-beta.16\r\n@angular-devkit/schematics 8.0.0-beta.16\r\n@angular/cli 8.0.0-beta.16\r\n@ngtools/webpack 8.0.0-beta.16\r\n@schematics/angular 8.0.0-beta.16\r\n@schematics/update 0.800.0-beta.16\r\nrxjs 6.4.0\r\ntypescript 3.4.4\r\nwebpack 4.30.0\r\n\u003c/code>\u003c/pre>\r\n\r\n**Anything else relevant?**\r\n\r\ncc @istiti\r\n\r\nThis is similar to https://github.com/angular/angular/issues/30106. In this case it is not a constructor parameter type, but rather a class property type.\r\n\r\nA class property by itself doesn't need metadata with a type reference:\r\n```\r\n// transpiled src/app/autocomplete.directive.ts without Input() decorator\r\nimport * as tslib_1 from \"tslib\";\r\nimport { Directive } from '@angular/core';\r\nlet AutocompleteDirective = class AutocompleteDirective {\r\n constructor() { }\r\n};\r\n// this is used in autocomplete.abstract.ts\r\nAutocompleteDirective.EMPTYLIST_ELEMENT = \"_EMPTYLIST_\";\r\nAutocompleteDirective = tslib_1.__decorate([\r\n Directive({\r\n selector: '[appAutocomplete]'\r\n }),\r\n tslib_1.__metadata(\"design:paramtypes\", [])\r\n], AutocompleteDirective);\r\nexport { AutocompleteDirective };\r\n```\r\n\r\nBut when the property is decorated, the metadata will contain a reference to the type:\r\n```\r\n// transpiled src/app/autocomplete.directive.ts with Input() decorator\r\nimport * as tslib_1 from \"tslib\";\r\nimport { Directive, Input } from '@angular/core';\r\nimport { AutocompleteAbstract } from './autocomplete.abstract';\r\nlet AutocompleteDirective = class AutocompleteDirective {\r\n constructor() { }\r\n};\r\n// this is used in autocomplete.abstract.ts\r\nAutocompleteDirective.EMPTYLIST_ELEMENT = \"_EMPTYLIST_\";\r\ntslib_1.__decorate([\r\n Input('appAutocomplete'),\r\n tslib_1.__metadata(\"design:type\", AutocompleteAbstract)\r\n], AutocompleteDirective.prototype, \"autocomplete\", void 0);\r\nAutocompleteDirective = tslib_1.__decorate([\r\n Directive({\r\n selector: '[appAutocomplete]'\r\n }),\r\n tslib_1.__metadata(\"design:paramtypes\", [])\r\n], AutocompleteDirective);\r\nexport { AutocompleteDirective };\r\n```\r\n\r\nIn ES5 there are no `class` declarations, so TS instead uses a `var`. One important different between `var` and `class/let/const` is that the latter are all subject to the [Temporal Dead Zone](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone). \r\n\r\nWithout the `Input()` decorator this isn't a problem because there is no circular dependency on the type.\r\n\r\n\r\n","author":{"url":"https://github.com/filipesilva","@type":"Person","name":"filipesilva"},"datePublished":"2019-04-26T10:03:37Z","url":"https://github.com/angular/angular/issues/30141"}
| 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:a18d30d5-4878-6182-7efa-1abf6d1ed09d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0CA:1F65:174F8D8:1D9CA8F:6B0196CC |
| html-safe-nonce | 1281530b5d7a964ecd97f12a6a5ad0ff39dc5db798d8c3d2f95dc3a8e24166e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMENBOjFGNjU6MTc0RjhEODoxRDlDQThGOjZCMDE5NkNDIiwidmlzaXRvcl9pZCI6IjQ3ODM4MjM4OTQyMTk5NTM4NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a764d76cd0a3942566864914eda508b5cb7ec3e9dd490695a598c8d6fa9054dd |
| hovercard-subject-tag | issue:437598233 |
| 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/30141/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3db8c3519ac6ed3527ec55cb801f6b0cdbd3caa837b32e3184f1635d4d461e17/angular/angular/issues/30141 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3db8c3519ac6ed3527ec55cb801f6b0cdbd3caa837b32e3184f1635d4d461e17/angular/angular/issues/30141 |
| og:image:alt | 🐞 bug report Affected Package The issue is caused by package @angular/core Is this a regression? No Description Using the `@Input()` property decorator (or any other property decorators I imagine) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | filipesilva |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width