Skip to content

strictProxy<T>

Creates a strictly-typed mock object from a partial implementation. Uses a Proxy that throws a descriptive error when any unmocked property is accessed, preventing silent undefined returns.

  • Idempotent: double-wrapping is a no-op. - Passthrough for well-known props (then, toJSON, Symbol.iterator, etc.). - Recursive proxying of nested plain objects.

Import:

import { strictProxy } from 'obsidian-dev-utils/strict-proxy';

Signature:

function strictProxy(partial: StrictProxyPartial<T>): T

Parameters:

ParameterTypeDescription
partialStrictProxyPartial<T>A partial object containing only the mocked members.

Returns: T — A proxy typed as T that throws on unmocked property access.