Skip to content

extend

extend: {<That>(that): <Self>(self) => extend<Self, That>; <Self, That>(self, that): extend<Self, That>; }

Defined in: node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/dts/Schema.d.ts:1650

Extends a schema with another schema.

Not all extensions are supported, and their support depends on the nature of the involved schemas.

Possible extensions include:

  • Schema.String with another Schema.String refinement or a string literal
  • Schema.Number with another Schema.Number refinement or a number literal
  • Schema.Boolean with another Schema.Boolean refinement or a boolean literal
  • A struct with another struct where overlapping fields support extension
  • A struct with in index signature
  • A struct with a union of supported schemas
  • A refinement of a struct with a supported schema
  • A suspend of a struct with a supported schema
  • A transformation between structs where the “from” and “to” sides have no overlapping fields with the target struct

<That>(that): <Self>(self) => extend<Self, That>

Extends a schema with another schema.

Not all extensions are supported, and their support depends on the nature of the involved schemas.

Possible extensions include:

  • Schema.String with another Schema.String refinement or a string literal
  • Schema.Number with another Schema.Number refinement or a number literal
  • Schema.Boolean with another Schema.Boolean refinement or a boolean literal
  • A struct with another struct where overlapping fields support extension
  • A struct with in index signature
  • A struct with a union of supported schemas
  • A refinement of a struct with a supported schema
  • A suspend of a struct with a supported schema
  • A transformation between structs where the “from” and “to” sides have no overlapping fields with the target struct

That extends Any

That

<Self>(self): extend<Self, That>

Self extends Any

Self

extend<Self, That>

import * as Schema from "effect/Schema"
const schema = Schema.Struct({
a: Schema.String,
b: Schema.String
})
// const extended: Schema<
// {
// readonly a: string
// readonly b: string
// } & {
// readonly c: string
// } & {
// readonly [x: string]: string
// }
// >
const extended = Schema.asSchema(schema.pipe(
Schema.extend(Schema.Struct({ c: Schema.String })), // <= you can add more fields
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.String })) // <= you can add index signatures
))

3.10.0

<Self, That>(self, that): extend<Self, That>

Extends a schema with another schema.

Not all extensions are supported, and their support depends on the nature of the involved schemas.

Possible extensions include:

  • Schema.String with another Schema.String refinement or a string literal
  • Schema.Number with another Schema.Number refinement or a number literal
  • Schema.Boolean with another Schema.Boolean refinement or a boolean literal
  • A struct with another struct where overlapping fields support extension
  • A struct with in index signature
  • A struct with a union of supported schemas
  • A refinement of a struct with a supported schema
  • A suspend of a struct with a supported schema
  • A transformation between structs where the “from” and “to” sides have no overlapping fields with the target struct

Self extends Any

That extends Any

Self

That

extend<Self, That>

import * as Schema from "effect/Schema"
const schema = Schema.Struct({
a: Schema.String,
b: Schema.String
})
// const extended: Schema<
// {
// readonly a: string
// readonly b: string
// } & {
// readonly c: string
// } & {
// readonly [x: string]: string
// }
// >
const extended = Schema.asSchema(schema.pipe(
Schema.extend(Schema.Struct({ c: Schema.String })), // <= you can add more fields
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.String })) // <= you can add index signatures
))

3.10.0

import * as Schema from "effect/Schema"
const schema = Schema.Struct({
a: Schema.String,
b: Schema.String
})
// const extended: Schema<
// {
// readonly a: string
// readonly b: string
// } & {
// readonly c: string
// } & {
// readonly [x: string]: string
// }
// >
const extended = Schema.asSchema(schema.pipe(
Schema.extend(Schema.Struct({ c: Schema.String })), // <= you can add more fields
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.String })) // <= you can add index signatures
))

3.10.0