Skip to content

Commit

Permalink
docs(core): Deprecate ChangeDetectorRef.checkNoChanges (#52431)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
atscott authored and alxhub committed Oct 31, 2023
1 parent 3f45682 commit 59b6ec6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions goldens/public-api/core/index.md
Expand Up @@ -168,6 +168,7 @@ export enum ChangeDetectionStrategy {

// @public
export abstract class ChangeDetectorRef {
// @deprecated
abstract checkNoChanges(): void;
abstract detach(): void;
abstract detectChanges(): void;
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/change_detection/change_detector_ref.ts
Expand Up @@ -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;

Expand Down

0 comments on commit 59b6ec6

Please sign in to comment.