refactor(core): drop computation error messages in production (#60700)

Some of the error messages in `core/primitives` are already guarded with `ngDevMode`; this change guards the remaining ones.

PR Close #60700
This commit is contained in:
arturovt
2025-04-02 18:57:49 +03:00
committed by Andrew Kushnir
parent 4c26b91015
commit c276981dfd
3 changed files with 15 additions and 3 deletions
@@ -133,7 +133,9 @@ const COMPUTED_NODE = /* @__PURE__ */ (() => {
producerRecomputeValue(node: ComputedNode<unknown>): void {
if (node.value === COMPUTING) {
// Our computation somehow led to a cyclic read of itself.
throw new Error('Detected cycle in computations.');
throw new Error(
typeof ngDevMode !== 'undefined' && ngDevMode ? 'Detected cycle in computations.' : '',
);
}
const oldValue = node.value;
@@ -137,7 +137,9 @@ export const LINKED_SIGNAL_NODE = /* @__PURE__ */ (() => {
producerRecomputeValue(node: LinkedSignalNode<unknown, unknown>): void {
if (node.value === COMPUTING) {
// Our computation somehow led to a cyclic read of itself.
throw new Error('Detected cycle in computations.');
throw new Error(
typeof ngDevMode !== 'undefined' && ngDevMode ? 'Detected cycle in computations.' : '',
);
}
const oldValue = node.value;
@@ -18,6 +18,10 @@ import {
SIGNAL,
} from './graph';
// Required as the signals library is in a separate package, so we need to explicitly ensure the
// global `ngDevMode` type is defined.
declare const ngDevMode: boolean | undefined;
/**
* A cleanup function that can be optionally registered from the watch logic. If registered, the
* cleanup logic runs before the next watch execution.
@@ -99,7 +103,11 @@ export function createWatch(
}
if (isInNotificationPhase()) {
throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
throw new Error(
typeof ngDevMode !== 'undefined' && ngDevMode
? 'Schedulers cannot synchronously execute watches while scheduling.'
: '',
);
}
node.dirty = false;