diff --git a/src/runtime/reactivity.ts b/src/runtime/reactivity.ts index 19610535..7d61f97f 100644 --- a/src/runtime/reactivity.ts +++ b/src/runtime/reactivity.ts @@ -1,8 +1,13 @@ -import { Callback } from "./utils"; +import type { Callback } from "./utils"; import { OwlError } from "./error_handling"; // Special key to subscribe to, to be notified of key creation/deletion const KEYCHANGES = Symbol("Key changes"); +// Used to specify the absence of a callback, can be used as WeakMap key but +// should only be used as a sentinel value and never called. +const NO_CALLBACK = () => { + throw new Error("Called NO_CALLBACK. Owl is broken, please report this to the maintainers."); +}; // The following types only exist to signify places where objects are expected // to be reactive or not, they provide no type checking benefit over "object" @@ -86,6 +91,9 @@ const targetToKeysToCallbacks = new WeakMap>>() * reactive has changed * @returns a proxy that tracks changes to it */ -export function reactive(target: T, callback: Callback = () => {}): T { +export function reactive(target: T, callback: Callback = NO_CALLBACK): T { if (!canBeMadeReactive(target)) { throw new OwlError(`Cannot make the given value reactive`); }