From 3c4deaa52bb42130f90126f55786331aa8b4f7dc Mon Sep 17 00:00:00 2001 From: Matthieu Riegler Date: Tue, 10 Feb 2026 15:04:45 +0100 Subject: [PATCH] refactor(common): log a warning when a JsonPipe receives a signal The JsonPipe does not unwrap signals and `JSON.stringify` will return `undefined` for signals. To avoid confusion, we log a warning when a signal is passed to the pipe. (cherry picked from commit 0d652ba4da68959addc8dc2e7a9076fc745b6ead) --- packages/common/src/pipes/json_pipe.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/common/src/pipes/json_pipe.ts b/packages/common/src/pipes/json_pipe.ts index 5db17d34919..eba55b6cb20 100644 --- a/packages/common/src/pipes/json_pipe.ts +++ b/packages/common/src/pipes/json_pipe.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.dev/license */ -import {Pipe, PipeTransform} from '@angular/core'; +import {isSignal, Pipe, PipeTransform} from '@angular/core'; /** * @ngModule CommonModule @@ -34,6 +34,10 @@ export class JsonPipe implements PipeTransform { * @param value A value of any type to convert into a JSON-format string. */ transform(value: any): string { + if (ngDevMode && isSignal(value)) { + console.warn(`The JsonPipe does not unwrap signals. Received a signal with value:`, value()); + } + return JSON.stringify(value, null, 2); } }