From 31453c08b3053ad5a644c5fbd0883521bde85bc9 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Fri, 27 Oct 2023 14:09:01 -0700 Subject: [PATCH] docs(core): Deprecate `ChangeDetectorRef.checkNoChanges` (#52431) The `checkNoChanges` method does not belong in the API of production interface. `checkNoChanges` is limited to testing and should not be used in any application code. Test code should use `ComponentFixture` instead of `ChangeDetectorRef`. Additionally, it is not desirable to have the `checkNoChanges` API available in a context where `detectChanges` is not run first. DEPRECATED: `ChangeDetectorRef.checkNoChanges` is deprecated. Test code should use `ComponentFixture` instead of `ChangeDetectorRef`. Application code should not call `ChangeDetectorRef.checkNoChanges` directly. PR Close #52431 --- goldens/public-api/core/index.md | 1 + packages/core/src/change_detection/change_detector_ref.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/goldens/public-api/core/index.md b/goldens/public-api/core/index.md index 1144346016742..e0c06b1c2ee6d 100644 --- a/goldens/public-api/core/index.md +++ b/goldens/public-api/core/index.md @@ -168,6 +168,7 @@ export enum ChangeDetectionStrategy { // @public export abstract class ChangeDetectorRef { + // @deprecated abstract checkNoChanges(): void; abstract detach(): void; abstract detectChanges(): void; diff --git a/packages/core/src/change_detection/change_detector_ref.ts b/packages/core/src/change_detection/change_detector_ref.ts index 6bd0102fdc4a8..4dc711d5ba58f 100644 --- a/packages/core/src/change_detection/change_detector_ref.ts +++ b/packages/core/src/change_detection/change_detector_ref.ts @@ -104,6 +104,10 @@ export abstract class ChangeDetectorRef { * * Use in development mode to verify that running change detection doesn't introduce * other changes. Calling it in production mode is a noop. + * + * @deprecated This is a test-only API that does not have a place in production interface. + * `checkNoChanges` is already part of an `ApplicationRef` tick when the app is running in dev + * mode. For more granular `checkNoChanges` validation, use `ComponentFixture`. */ abstract checkNoChanges(): void;