Title: compiler-cli: lowering_expression transformer does not handle forwardRef like function · Issue #20216 · angular/angular · GitHub
Open Graph Title: compiler-cli: lowering_expression transformer does not handle forwardRef like function · Issue #20216 · angular/angular
X Title: compiler-cli: lowering_expression transformer does not handle forwardRef like function · Issue #20216 · angular/angular
Description: @Component({ selector: 'app-test-component', templateUrl: './test-component.component.html', styleUrls: ['./test-component.component.css'] }) export class TestComponentComponent { prop: string; } export function MyPropDecorator(value: an...
Open Graph Description: @Component({ selector: 'app-test-component', templateUrl: './test-component.component.html', styleUrls: ['./test-component.component.css'] }) export class TestComponentComponent { prop: string; } e...
X Description: @Component({ selector: 'app-test-component', templateUrl: './test-component.component.html', styleUrls: ['./test-component.component.css'] }) export class TestComponentCompo...
Opengraph URL: https://github.com/angular/angular/issues/20216
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"compiler-cli: lowering_expression transformer does not handle forwardRef like function","articleBody":"```ts\r\n@Component({\r\n selector: 'app-test-component',\r\n templateUrl: './test-component.component.html',\r\n styleUrls: ['./test-component.component.css']\r\n})\r\nexport class TestComponentComponent {\r\n prop: string;\r\n}\r\n\r\nexport function MyPropDecorator(value: any) {\r\n return (target: Object, key: string) => { }\r\n}\r\n\r\nexport class MyClass {\r\n @MyPropDecorator(() => TestComponentComponent)\r\n prop: string;\r\n}\r\n```\r\n\r\n```bash\r\nSHLASSAF-M-4099:testproj shlomiassaf$ ng build --aot --build-optimizer\r\nDate: 2017-11-06T04:02:00.134Z \r\nHash: 957bab95fbd81c3b3b0f\r\nTime: 3658ms\r\nchunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]\r\nchunk {main} main.bundle.js, main.bundle.js.map (main) 303 bytes [initial] [rendered]\r\nchunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 323 bytes [initial] [rendered]\r\nchunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.3 kB [initial] [rendered]\r\n\r\nERROR in Error: TypeError: Cannot read property 'kind' of undefined\r\n at nodeCanBeDecorated (/Users/shlomiassaf/Desktop/Cisco/personal/testproj/node_modules/typescript/lib/typescript.js:7805:35)\r\n```\r\n\r\n> Its not `@angualr-devkit/build-optimizer`, i removed it from the command line, still errors.\r\n### This will work:\r\n```\r\nexport function MyPropDecorator(value: any) {\r\n return (target: Object, key: string) => { }\r\n}\r\n\r\nexport class MyClass {\r\n @MyPropDecorator(TestComponentComponent)\r\n prop: string;\r\n}\r\n```\r\n\r\n### Being explicit won't help\r\n```ts\r\nexport function MyPropDecorator(value: () => typeof TestComponentComponent) {\r\n return (target: Object, key: string) => { }\r\n}\r\n\r\nexport class MyClass {\r\n @MyPropDecorator(() => TestComponentComponent)\r\n prop: string;\r\n}\r\n```\r\n\r\n### BUT, being static will help:\r\n```ts\r\nexport function MyPropDecorator(value: () => typeof TestComponentComponent) {\r\n return (target: Object, key: string) => { }\r\n}\r\n\r\nexport function MyGetter() {\r\n return TestComponentComponent;\r\n}\r\n\r\nexport class MyClass {\r\n @MyPropDecorator(MyGetter)\r\n prop: string;\r\n}\r\n```\r\n\r\nThanks!\r\n\r\n``` \r\nAngular CLI: 1.5.0\r\nNode: 8.4.0\r\nOS: darwin x64\r\nAngular: 5.0.0\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... http, language-service, platform-browser\r\n... platform-browser-dynamic, router\r\n\r\n@angular/cli: 1.5.0\r\n@angular-devkit/build-optimizer: 0.0.32\r\n@angular-devkit/core: 0.0.20\r\n@angular-devkit/schematics: 0.0.35\r\n@ngtools/json-schema: 1.1.0\r\n@ngtools/webpack: 1.8.0\r\n@schematics/angular: 0.1.0\r\ntypescript: 2.4.2\r\nwebpack: 3.8.1\r\n```\r\n","author":{"url":"https://github.com/shlomiassaf","@type":"Person","name":"shlomiassaf"},"datePublished":"2017-11-06T10:22:24Z","url":"https://github.com/angular/angular/issues/20216"}
| 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:10e8c2bb-7493-271b-0e8e-aff6d1a4c323 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB42:FC5BE:2583DCB:31CF537:6B019F86 |
| html-safe-nonce | b223611795a684792108bb118e6c5f0e493a0e075bbab5ddef0c7a8fb122787c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjQyOkZDNUJFOjI1ODNEQ0I6MzFDRjUzNzo2QjAxOUY4NiIsInZpc2l0b3JfaWQiOiI3ODgyMzIxOTQ3MDQ3MDc1NzE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3cecb1b64a32b8ebcbfb66278e726dfb6bf27215f653bf46cdb9f71b054613e4 |
| hovercard-subject-tag | issue:271424135 |
| 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/20216/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a8a18e2fe3c78ebafe6ec49f21e404994a78da4945233ab61e60699d97e99f85/angular/angular/issues/20216 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a8a18e2fe3c78ebafe6ec49f21e404994a78da4945233ab61e60699d97e99f85/angular/angular/issues/20216 |
| og:image:alt | @Component({ selector: 'app-test-component', templateUrl: './test-component.component.html', styleUrls: ['./test-component.component.css'] }) export class TestComponentComponent { prop: string; } e... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shlomiassaf |
| 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