strict-proxy
Strictly-typed mock object factory via Proxy. Throws a descriptive error when any unmocked property is accessed, preventing silent undefined returns.
The proxy implementation mirrors the design of obsidian-test-mocks/src/internal/strict-proxy.ts.
Functions
Section titled “Functions”| Function | Description |
|---|---|
| bypassStrictProxy | Bypasses strict proxy to access the underlying object. If the object is wrapped in a strict proxy, returns the unwrapped target. Otherwise, returns the object as-is. This allows safely accessing optional properties without triggering the proxy’s error on missing props. |
| strictProxy | 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. |
| Type | Description |
|---|---|
| StrictProxyPartial | A recursive partial type compatible with exactOptionalPropertyTypes. Unlike PartialDeep from type-fest, this type allows full T values at any nesting level via the | T[K] union. This is essential for composing nested strictProxy calls — an inner strictProxy<MetadataCache>(\{...\}) returns MetadataCache, which must be assignable to the outer partial type. |