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.Stringwith anotherSchema.Stringrefinement or a string literalSchema.Numberwith anotherSchema.Numberrefinement or a number literalSchema.Booleanwith anotherSchema.Booleanrefinement 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
Call Signature
Section titled “Call Signature”<
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.Stringwith anotherSchema.Stringrefinement or a string literalSchema.Numberwith anotherSchema.Numberrefinement or a number literalSchema.Booleanwith anotherSchema.Booleanrefinement 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
Type Parameters
Section titled “Type Parameters”That extends Any
Parameters
Section titled “Parameters”That
Returns
Section titled “Returns”<
Self>(self):extend<Self,That>
Type Parameters
Section titled “Type Parameters”Self extends Any
Parameters
Section titled “Parameters”Self
Returns
Section titled “Returns”extend<Self, That>
Example
Section titled “Example”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
Call Signature
Section titled “Call Signature”<
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.Stringwith anotherSchema.Stringrefinement or a string literalSchema.Numberwith anotherSchema.Numberrefinement or a number literalSchema.Booleanwith anotherSchema.Booleanrefinement 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
Type Parameters
Section titled “Type Parameters”Self extends Any
That extends Any
Parameters
Section titled “Parameters”Self
That
Returns
Section titled “Returns”extend<Self, That>
Example
Section titled “Example”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
Example
Section titled “Example”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