Skip to content

Commit

Permalink
fix(core): tree shake dev mode error message (#57035)
Browse files Browse the repository at this point in the history
Adds an `ngDevMode` check before a runtime error message.

Fixes #57034.

PR Close #57035
  • Loading branch information
crisbeto authored and atscott committed Jul 22, 2024
1 parent 21f7131 commit fe41b11
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/rxjs-interop/src/to_signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,11 @@ export function toSignal<T, U = undefined>(
// "complete".
});

if (ngDevMode && options?.requireSync && state().kind === StateKind.NoValue) {
if (options?.requireSync && state().kind === StateKind.NoValue) {
throw new ɵRuntimeError(
ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,
'`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',
(typeof ngDevMode === 'undefined' || ngDevMode) &&
'`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',
);
}

Expand All @@ -205,10 +206,10 @@ export function toSignal<T, U = undefined>(
throw current.error;
case StateKind.NoValue:
// This shouldn't really happen because the error is thrown on creation.
// TODO(alxhub): use a RuntimeError when we finalize the error semantics
throw new ɵRuntimeError(
ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,
'`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',
(typeof ngDevMode === 'undefined' || ngDevMode) &&
'`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',
);
}
},
Expand Down

0 comments on commit fe41b11

Please sign in to comment.