Skip to content

Commit 75b0386

Browse files
committed
fix(schema): build the lazy schema on first call
1 parent 29d99f8 commit 75b0386

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/schema/lazy.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ export function memoSchema<T>(build: () => T): () => T {
2424
* instead of passing this object into `type()`.
2525
*/
2626
export function lazyCallable<T extends object>(load: () => T): T {
27-
return new Proxy(function lazySchema() {} as unknown as T, {
27+
function lazySchema(this: unknown, ...args: unknown[]) {
28+
const schema = load() as (...args: unknown[]) => unknown;
29+
return Reflect.apply(schema, this, args);
30+
}
31+
return new Proxy(lazySchema as unknown as T, {
2832
apply(_target, thisArg, argArray) {
2933
const schema = load() as (...args: unknown[]) => unknown;
3034
return Reflect.apply(schema, thisArg, argArray);

0 commit comments

Comments
 (0)