(objectType: z.ZodType)
| 186 | } |
| 187 | |
| 188 | function appendObjectType(objectType: z.ZodType) { |
| 189 | append("{"); |
| 190 | appendNewLine(); |
| 191 | indent++; |
| 192 | for (let [name, type] of Object.entries((objectType._zod.def as z.core.$ZodObjectDef).shape) as [string, z.ZodType][]) { |
| 193 | let inlineComment: string | undefined; |
| 194 | if (getTypeKind(type) === "optional") { |
| 195 | const wrapperDescription = type.description; |
| 196 | if (wrapperDescription) { |
| 197 | for (const line of wrapperDescription.split("\n")) { |
| 198 | append(`// ${line}`); |
| 199 | appendNewLine(); |
| 200 | } |
| 201 | } |
| 202 | append(name); |
| 203 | append("?"); |
| 204 | type = (type._zod.def as z.core.$ZodOptionalDef).innerType as z.ZodType; |
| 205 | } else { |
| 206 | inlineComment = type.description; |
| 207 | append(name); |
| 208 | } |
| 209 | append(": "); |
| 210 | appendType(type); |
| 211 | append(";"); |
| 212 | if (inlineComment) append(` // ${inlineComment}`); |
| 213 | appendNewLine(); |
| 214 | } |
| 215 | indent--; |
| 216 | append("}"); |
| 217 | } |
| 218 | |
| 219 | function appendUnionOrIntersectionTypes(types: readonly z.ZodType[], minPrecedence: TypePrecedence) { |
| 220 | let first = true; |
no test coverage detected