(mapping: M)
| 3492 | * after the transformation. |
| 3493 | */ |
| 3494 | mapFields<To extends Struct.Fields>( |
| 3495 | f: (fields: Fields) => To, |
| 3496 | options?: { |
| 3497 | readonly unsafePreserveChecks?: boolean | undefined |
| 3498 | } | undefined |
| 3499 | ): Struct<Simplify<Readonly<To>>> |
| 3500 | } |
| 3501 | |
| 3502 | function makeStruct<const Fields extends Struct.Fields>(ast: SchemaAST.Objects, fields: Fields): Struct<Fields> { |
| 3503 | return make(ast, { |
| 3504 | fields, |
| 3505 | mapFields<To extends Struct.Fields>( |
| 3506 | this: Struct<Fields>, |
| 3507 | f: (fields: Fields) => To, |
| 3508 | options?: { |
| 3509 | readonly unsafePreserveChecks?: boolean | undefined |
| 3510 | } | undefined |
| 3511 | ): Struct<To> { |
| 3512 | const fields = f(this.fields) |
| 3513 | return makeStruct(SchemaAST.struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields) |
| 3514 | } |
| 3515 | }) |
| 3516 | } |
| 3517 | |
| 3518 | /** |
| 3519 | * Defines a struct schema from a map of field schemas. |
| 3520 | * |
| 3521 | * **Details** |
| 3522 | * |
| 3523 | * Each field value is a schema. Use {@link optionalKey} or {@link optional} to |
| 3524 | * mark fields as optional, and {@link mutableKey} to mark them as mutable. |
| 3525 | * |
| 3526 | * The resulting schema's `Type` is a readonly object type with the fields' |
| 3527 | * decoded types. The `Encoded` form mirrors the field schemas' encoded types. |
| 3528 | * |
| 3529 | * **Example** (Defining a basic struct) |
nothing calls this directly
no test coverage detected
searching dependent graphs…