Title: Detect missing imports in standalone components · Issue #46661 · angular/angular · GitHub
Open Graph Title: Detect missing imports in standalone components · Issue #46661 · angular/angular
X Title: Detect missing imports in standalone components · Issue #46661 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? compiler Description If a directive has an attribute selector and the attribute is used without square brackets, such as routerLink="/users", and we forget to impor...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? compiler Description If a directive has an attribute selector and the attribute is used without square brackets, such as rou...
X Description: Which @angular/* package(s) are relevant/related to the feature request? compiler Description If a directive has an attribute selector and the attribute is used without square brackets, such as rou...
Opengraph URL: https://github.com/angular/angular/issues/46661
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Detect missing imports in standalone components","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\r\n\r\ncompiler\r\n\r\n### Description\r\n\r\nIf a directive has an attribute selector and the attribute is used without square brackets, such as `routerLink=\"/users\"`, and we forget to import the directive, or the module defining the directive, then the compiler doesn't complain at all, and we end up with an unnoticed bug.\r\n\r\nWhen using NgModules, such a bug happens rarely, because you rarely forget to import the router module (for example) in your main or feature module. But when using standalone components, it's much more frequent, because the import needs to be repeated on every component that needs the directive, and of course we tend to only import what's absolutely needed.\r\n\r\nAfter migrating two relatively small applications to standalone components, I've introduced such a bug, especially with routerLink, at least twice. \r\n\r\nI understand why the compiler doesn't complain, but this, IMHO, is a source of hard to detect bugs: I doubt most people have integration tests checking that each and every link in their components works as expected. And even at runtime, the bug goes unnoticed until you click on the link and realize it doesn't work.\r\n\r\n\r\n### Proposed solution\r\n\r\nIt would be nice to be able to activate some compiler option that would, for example, check that any non-standard HTML attribute used in a component (such as `routerLink`) matches with a known directive selector for that component.\r\n\r\nOr to be able to provide a list of selectors or attributes that must be checked.\r\n\r\n### Alternatives considered\r\n\r\nI don't see any.","author":{"url":"https://github.com/jnizet","@type":"Person","name":"jnizet"},"datePublished":"2022-07-01T09:04:41Z","url":"https://github.com/angular/angular/issues/46661"}
| 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:2b8a20db-a828-010f-6a22-3a0dba1dc951 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9D8:D0E46:C02353:FEFD22:6B00F29E |
| html-safe-nonce | e7a3734c19959c74124a9b25490fc18818fb80fe03dca461d5c4c780f5ae9fa9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUQ4OkQwRTQ2OkMwMjM1MzpGRUZEMjI6NkIwMEYyOUUiLCJ2aXNpdG9yX2lkIjoiODc1Mjc1Nzk3OTc4NDc3MjE0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e235bd8c5eaddeb7cb1df1c0487d35c85d91deaf1a62a47fdba49137eff148a0 |
| hovercard-subject-tag | issue:1291128883 |
| 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/46661/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c80cbacc87033b6da790f324d214e08db170eb15b1ee3e77a4f5b41befb289ac/angular/angular/issues/46661 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c80cbacc87033b6da790f324d214e08db170eb15b1ee3e77a4f5b41befb289ac/angular/angular/issues/46661 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? compiler Description If a directive has an attribute selector and the attribute is used without square brackets, such as rou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jnizet |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width