Title: Is it by design that Angular does not notice array changes during the second check in development mode? · Issue #43187 · angular/angular · GitHub
Open Graph Title: Is it by design that Angular does not notice array changes during the second check in development mode? · Issue #43187 · angular/angular
X Title: Is it by design that Angular does not notice array changes during the second check in development mode? · Issue #43187 · angular/angular
Description: @Pipe({ name: 'reverse', pure: false }) export class ReversePipe implements PipeTransform { transform
Open Graph Description: @Pipe({ name: 'reverse', pure: false }) export class ReversePipe implements PipeTransform { transform
X Description: @Pipe({ name: 'reverse', pure: false }) export class ReversePipe implements PipeTransform { transform<T>(value: T[]): T[] { return value.reverse(); } } This is how an unexperienced or...
Opengraph URL: https://github.com/angular/angular/issues/43187
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Is it by design that Angular does not notice array changes during the second check in development mode?","articleBody":"```typescript\r\n@Pipe({\r\n name: 'reverse',\r\n pure: false\r\n})\r\nexport class ReversePipe implements PipeTransform {\r\n transform\u003cT>(value: T[]): T[] {\r\n return value.reverse();\r\n }\r\n}\r\n```\r\n\r\nThis is how an unexperienced or forgetful developer could try to implement a pipe that reverses arrays. This naive implementation is wrong because `reverse()` reverses arrays in-place, so I would expect an `ExpressionChangedAfterItHasBeenChecked` error to be thrown in development mode. But not only is there no such error, the app even seems to work completely fine. The reason is that the array is reversed one more time during the second check, which brings it in its original order. But we cannot see it reflected in the UI because the rendering has already been completed at the time of the second check.\r\n\r\nWhat is even more interesting is that there is no error even if we return a copy of the array we have just reversed,\r\n\r\n```typescript\r\ntransform\u003cT>(value: T[]): T[] {\r\n value.reverse();\r\n return [...value];\r\n}\r\n```\r\n\r\nso the problem has not only to do with the fact that the array reference does not change.\r\n\r\nIn both cases, the problem first becomes apparent when the app is built for production, meaning that the second check hides the problem instead of reporting it. Does not that contradict the purpose of the second check? Is it desired that it works this way?","author":{"url":"https://github.com/aweebit","@type":"Person","name":"aweebit"},"datePublished":"2021-08-17T19:34:09Z","url":"https://github.com/angular/angular/issues/43187"}
| 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:b134e65e-e326-0dc5-a50f-7520768964d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EDA:25A901:E75F9E:13C6DC7:6B045D8C |
| html-safe-nonce | a32710c6d89b1646701f6a94d540f0020dafef3173401a53086d41aec7d2d834 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RURBOjI1QTkwMTpFNzVGOUU6MTNDNkRDNzo2QjA0NUQ4QyIsInZpc2l0b3JfaWQiOiI4MTk5OTkxNTQwODc0MjM5MzcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2cda396d967eac31dc7b99859ae68a37bde4dccaa9174838be0e77f23fca902d |
| hovercard-subject-tag | issue:973002808 |
| 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/43187/issue_layout |
| twitter:image | https://opengraph.githubassets.com/215e4777e129dfa8f0db9b89bed09423db1d6cd53826dd11ef25770b342d38a5/angular/angular/issues/43187 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/215e4777e129dfa8f0db9b89bed09423db1d6cd53826dd11ef25770b342d38a5/angular/angular/issues/43187 |
| og:image:alt | @Pipe({ name: 'reverse', pure: false }) export class ReversePipe implements PipeTransform { transform |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aweebit |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| 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 | 03e114520787ad27289207f153520ef97461127c |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width