diff --git a/src/index.ts b/src/index.ts index 92a0258d4..a6b3a3d04 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import DateSchema, { create as dateCreate } from './date'; import ObjectSchema, { AnyObject, create as objectCreate } from './object'; import ArraySchema, { create as arrayCreate } from './array'; import { create as refCreate } from './Reference'; -import { create as lazyCreate } from './Lazy'; +import Lazy, { create as lazyCreate } from './Lazy'; import ValidationError from './ValidationError'; import reach from './util/reach'; import isSchema from './util/isSchema'; @@ -37,11 +37,11 @@ function addMethod(schemaType: any, name: string, fn: any) { schemaType.prototype[name] = fn; } -type SchemaOf = T extends AnyObject - ? ObjectSchema<{ [k in keyof T]: SchemaOf }> - : T extends Array - ? ArraySchema> - : BaseSchema, AnyObject, T>; +type SchemaOf = T extends Array + ? ArraySchema | Lazy>> + : T extends AnyObject + ? ObjectSchema<{ [K in keyof T]: SchemaOf }> + : BaseSchema, AnyObject, T>; export type AnyObjectSchema = ObjectSchema; export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema };