@@ -97,6 +97,8 @@ function renderTypeInternal(
9797 return renderUnion ( schema as s . UnionSchema , ctx , skipUndefined ) ;
9898 case s . record :
9999 return renderRecord ( schema as s . RecordSchema , ctx , skipUndefined ) ;
100+ case s . lazy :
101+ return renderLazy ( schema as s . LazySchema , ctx , skipUndefined ) ;
100102 default :
101103 throw new Error ( `Unsupported schema ${ schema . type . name } ` ) ;
102104 }
@@ -158,6 +160,12 @@ function renderRecord(schema: s.RecordSchema, ctx: RenderContext, skipUndefined?
158160 return wrapType ( schema , type , skipUndefined ) ;
159161}
160162
163+ function renderLazy ( schema : s . LazySchema , ctx : RenderContext , skipUndefined ?: boolean ) {
164+ const unwrapped = unwrapLazy ( schema ) ;
165+ const type = renderTypeInternal ( unwrapped , ctx , skipUndefined ) ;
166+ return wrapType ( unwrapped , type , skipUndefined ) ;
167+ }
168+
161169function renderEnum ( schema : s . EnumSchema , skipUndefined ?: boolean ) {
162170 const type = schema . values . map ( option => `"${ option } "` ) . join ( ' | ' ) ;
163171 return wrapType ( schema , type , skipUndefined ) ;
@@ -186,3 +194,16 @@ function findUniqueName(name: string, ctx: RenderContext) {
186194
187195 return uniqueName ;
188196}
197+
198+ function unwrapLazy ( schema : s . LazySchema ) {
199+ const inner = schema . of ( ) ;
200+
201+ const unwrapped : Partial < s . LazySchema > = schema ;
202+ delete unwrapped . of ;
203+
204+ for ( const key in inner ) {
205+ ( unwrapped as Record < string , unknown > ) [ key ] = inner [ key as keyof typeof inner ] ;
206+ }
207+
208+ return unwrapped as s . Schema ;
209+ }
0 commit comments