admin管理员组

文章数量:1391951

After updating from Angular 19.1.4 to 19.2.2, I get following error when using changeDetection: ChangeDetectionStrategy.OnPush:

changeDetection must be a member of ChangeDetectionStrategy enum from @angular/core
  Value is of type 'ChangeDetectionStrategy$1'.(-991010)

(ChangeDetectionStrategy is imported from @angular/core as this answer suggests.)

I had no errors before upgrading.

diff --git a/package.json b/package.json
index 0540c6d..31c4180 100644
--- a/package.json
+++ b/package.json
@@ -16,32 +16,32 @@
     "@angular/common": "^19.0.0",
     "@angular/compiler": "^19.0.0",
     "@angular/core": "^19.0.0",
-    "@angular/forms": "^19.1.4",
+    "@angular/forms": "^19.2.2",
     "@angular/platform-browser": "^19.0.0",
-    "@angular/platform-browser-dynamic": "^19.1.4",
-    "@angular/router": "^19.1.4",
-    "@angular/service-worker": "^19.1.4",
+    "@angular/platform-browser-dynamic": "^19.2.2",
+    "@angular/router": "^19.2.2",
+    "@angular/service-worker": "^19.2.2",
     "rxjs": "~7.8.0",
     "tslib": "^2.3.0"
   },
   "devDependencies": {
-    "@angular-devkit/build-angular": "^19.1.5",
-    "@angular/cli": "^19.1.5",
-    "@angular/compiler-cli": "^19.1.4",
+    "@angular-devkit/build-angular": "^19.2.2",
+    "@angular/cli": "^19.2.2",
+    "@angular/compiler-cli": "^19.2.2",
     "@eslint/css": "^0.1.0",
     "@eslint/js": "^9.17.0",
-    "@typescript-eslint/eslint-plugin": "^8.22.0",
-    "@typescript-eslint/parser": "^8.22.0",
+    "@typescript-eslint/eslint-plugin": "^8.26.1",
+    "@typescript-eslint/parser": "^8.26.1",
     "angular-eslint": "19.0.2",
-    "eslint": "^9.19.0",
-    "globals": "^15.14.0",
-    "ng-packagr": "^19.1.2",
+    "eslint": "^9.22.0",
+    "globals": "^15.15.0",
+    "ng-packagr": "^19.2.0",
     "typescript": "~5.6.2",
     "typescript-eslint": "8.18.0"
   }

Things I tried:

  • downgrading to 19.2.1 (same error)
  • rm -rf node_modules and npm install (same error)
  • change all remaining angular dependencies from 19.0.0 to 19.2.2 (same error)

Visual Studio Code's Angular Language Extension was up-to-date on my computer as of March 12. It turned out to be a bug in the extension, there is a new version released on March 13 that fixes the bug. See accepted answer.

After updating from Angular 19.1.4 to 19.2.2, I get following error when using changeDetection: ChangeDetectionStrategy.OnPush:

changeDetection must be a member of ChangeDetectionStrategy enum from @angular/core
  Value is of type 'ChangeDetectionStrategy$1'.(-991010)

(ChangeDetectionStrategy is imported from @angular/core as this answer suggests.)

I had no errors before upgrading.

diff --git a/package.json b/package.json
index 0540c6d..31c4180 100644
--- a/package.json
+++ b/package.json
@@ -16,32 +16,32 @@
     "@angular/common": "^19.0.0",
     "@angular/compiler": "^19.0.0",
     "@angular/core": "^19.0.0",
-    "@angular/forms": "^19.1.4",
+    "@angular/forms": "^19.2.2",
     "@angular/platform-browser": "^19.0.0",
-    "@angular/platform-browser-dynamic": "^19.1.4",
-    "@angular/router": "^19.1.4",
-    "@angular/service-worker": "^19.1.4",
+    "@angular/platform-browser-dynamic": "^19.2.2",
+    "@angular/router": "^19.2.2",
+    "@angular/service-worker": "^19.2.2",
     "rxjs": "~7.8.0",
     "tslib": "^2.3.0"
   },
   "devDependencies": {
-    "@angular-devkit/build-angular": "^19.1.5",
-    "@angular/cli": "^19.1.5",
-    "@angular/compiler-cli": "^19.1.4",
+    "@angular-devkit/build-angular": "^19.2.2",
+    "@angular/cli": "^19.2.2",
+    "@angular/compiler-cli": "^19.2.2",
     "@eslint/css": "^0.1.0",
     "@eslint/js": "^9.17.0",
-    "@typescript-eslint/eslint-plugin": "^8.22.0",
-    "@typescript-eslint/parser": "^8.22.0",
+    "@typescript-eslint/eslint-plugin": "^8.26.1",
+    "@typescript-eslint/parser": "^8.26.1",
     "angular-eslint": "19.0.2",
-    "eslint": "^9.19.0",
-    "globals": "^15.14.0",
-    "ng-packagr": "^19.1.2",
+    "eslint": "^9.22.0",
+    "globals": "^15.15.0",
+    "ng-packagr": "^19.2.0",
     "typescript": "~5.6.2",
     "typescript-eslint": "8.18.0"
   }

Things I tried:

  • downgrading to 19.2.1 (same error)
  • rm -rf node_modules and npm install (same error)
  • change all remaining angular dependencies from 19.0.0 to 19.2.2 (same error)

Visual Studio Code's Angular Language Extension was up-to-date on my computer as of March 12. It turned out to be a bug in the extension, there is a new version released on March 13 that fixes the bug. See accepted answer.

Share Improve this question edited Mar 13 at 12:02 Thomas asked Mar 12 at 19:59 ThomasThomas 10.3k17 gold badges53 silver badges97 bronze badges 5
  • This is symptom of dependency duplications. Basicaly your node modules has several @angular/core packages. – Matthieu Riegler Commented Mar 12 at 20:33
  • I am confused, everything worked with 19.1.4. No other changes than upgrading Angular to 19.2.2 has been made. – Thomas Commented Mar 12 at 20:37
  • And when I downgrade to 19.1.4, everything is fine again. – Thomas Commented Mar 12 at 20:39
  • Some dependency is probably pulling a different minor version. It's hard to say which one. You might want to analyze the bundle with ng build --stat-json angular.dev/cli/build – Matthieu Riegler Commented Mar 12 at 20:51
  • Merci Matthieu. It turned out to be a bug in the Angular Language Extension. They have released a new version this morning. – Thomas Commented Mar 13 at 11:53
Add a comment  | 

1 Answer 1

Reset to default 3

Update angular language extension to latest, They just released a fixed

本文标签: angular19changeDetection must be a member of ChangeDetectionStrategy enum from angularcoreStack Overflow