| 3519 | } |
| 3520 | |
| 3521 | function makeStruct<const Fields extends Struct.Fields>(ast: SchemaAST.Objects, fields: Fields): Struct<Fields> { |
| 3522 | return make(ast, { |
| 3523 | fields, |
| 3524 | mapFields<To extends Struct.Fields>( |
| 3525 | this: Struct<Fields>, |
| 3526 | f: (fields: Fields) => To, |
| 3527 | options?: { |
| 3528 | readonly unsafePreserveChecks?: boolean | undefined |
| 3529 | } | undefined |
| 3530 | ): Struct<To> { |
| 3531 | const fields = f(this.fields) |
| 3532 | return makeStruct(SchemaAST.struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields) |
| 3533 | } |
| 3534 | }) |
| 3535 | } |
| 3536 | |
| 3537 | /** |
| 3538 | * Defines a struct schema from a map of field schemas. |