TaggedStruct
TaggedStruct: <
Tag,Fields>(value,fields) =>TaggedStruct<Tag,Fields>
Defined in: node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/dts/Schema.d.ts:1399
A tagged struct is a struct that has a tag property that is used to distinguish between different types of objects.
The tag is optional when using the make method.
Type Parameters
Section titled “Type Parameters”Tag extends LiteralValue
Fields
Section titled “Fields”Fields extends Fields
Parameters
Section titled “Parameters”Tag
fields
Section titled “fields”Fields
Returns
Section titled “Returns”TaggedStruct<Tag, Fields>
Example
Section titled “Example”import * as assert from "node:assert"import { Schema } from "effect"
const User = Schema.TaggedStruct("User", { name: Schema.String, age: Schema.Number})
assert.deepStrictEqual(User.make({ name: "John", age: 44 }), { _tag: "User", name: "John", age: 44 })3.10.0