From 411511e002a5b9165ac9867fb8a7c53fe47d65a8 Mon Sep 17 00:00:00 2001 From: Claudia Meadows Date: Wed, 24 Apr 2024 11:10:12 -0700 Subject: [PATCH 1/2] Remove `ngDevMode` condition on error message Error messages shouldn't differ like that based on environment. It's also useful outside of Angular. --- packages/signal-polyfill/src/graph.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/signal-polyfill/src/graph.ts b/packages/signal-polyfill/src/graph.ts index f3e9dc5..3968488 100644 --- a/packages/signal-polyfill/src/graph.ts +++ b/packages/signal-polyfill/src/graph.ts @@ -214,10 +214,7 @@ interface ProducerNode extends ReactiveNode { */ export function producerAccessed(node: ReactiveNode): void { if (inNotificationPhase) { - throw new Error( - typeof ngDevMode !== 'undefined' && ngDevMode ? - `Assertion error: signal read during notification phase` : - ''); + throw new Error('Assertion error: signal read during notification phase'); } if (activeConsumer === null) { @@ -511,4 +508,4 @@ export function assertConsumerNode(node: ReactiveNode): asserts node is Consumer export function assertProducerNode(node: ReactiveNode): asserts node is ProducerNode { node.liveConsumerNode ??= []; node.liveConsumerIndexOfThis ??= []; -} \ No newline at end of file +} From a4774c22fac309ffb880dc84bb898403848699ce Mon Sep 17 00:00:00 2001 From: Claudia Meadows Date: Wed, 24 Apr 2024 11:19:07 -0700 Subject: [PATCH 2/2] Remove Angular-specific bits --- packages/signal-polyfill/src/graph.ts | 6 +----- packages/signal-polyfill/src/signal.ts | 4 ---- packages/signal-polyfill/src/wrapper.spec.ts | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/signal-polyfill/src/graph.ts b/packages/signal-polyfill/src/graph.ts index 3968488..2ed1bd1 100644 --- a/packages/signal-polyfill/src/graph.ts +++ b/packages/signal-polyfill/src/graph.ts @@ -6,10 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -// 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; - /** * The currently active consumer `ReactiveNode`, if running code in a reactive context. @@ -459,7 +455,7 @@ export function producerRemoveLiveConsumerAtIndex(node: ReactiveNode, idx: numbe assertProducerNode(node); assertConsumerNode(node); - if (typeof ngDevMode !== 'undefined' && ngDevMode && idx >= node.liveConsumerNode.length) { + if (idx >= node.liveConsumerNode.length) { throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${ node.liveConsumerNode.length} consumers)`); } diff --git a/packages/signal-polyfill/src/signal.ts b/packages/signal-polyfill/src/signal.ts index 2bdfba3..5e1e4a9 100644 --- a/packages/signal-polyfill/src/signal.ts +++ b/packages/signal-polyfill/src/signal.ts @@ -10,10 +10,6 @@ import {defaultEquals, ValueEqualityFn} from './equality.js'; import {throwInvalidWriteToSignalError} from './errors.js'; import {producerAccessed, producerIncrementEpoch, producerNotifyConsumers, producerUpdatesAllowed, REACTIVE_NODE, ReactiveNode, SIGNAL} from './graph.js'; -// 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; - /** * If set, called after `WritableSignal`s are updated. * diff --git a/packages/signal-polyfill/src/wrapper.spec.ts b/packages/signal-polyfill/src/wrapper.spec.ts index 1b50ef8..ef4e0d3 100644 --- a/packages/signal-polyfill/src/wrapper.spec.ts +++ b/packages/signal-polyfill/src/wrapper.spec.ts @@ -1048,5 +1048,4 @@ describe("currentComputed", () => { // - The code for the callbacks (for reading signals and running watches) // - Paths around writes being prohibited during computed/effect // - Setters for various hooks -// - ngDevMode // - Some predicates/getters for convenience, e.g., isReactive