effect-io-ai

Package: effect
Module: Schema

Schema.tag

Returns a property signature that represents a tag. A tag is a literal value that is used to distinguish between different types of objects. The tag is optional when using the make method.

Example

import * as assert from "node:assert"
import { Schema } from "effect"

const User = Schema.Struct({
  _tag: Schema.tag("User"),
  name: Schema.String,
  age: Schema.Number
})

assert.deepStrictEqual(User.make({ name: "John", age: 44 }), { _tag: "User", name: "John", age: 44 })

See

Signature

declare const tag: <Tag extends AST.LiteralValue>(tag: Tag) => tag<Tag>

Source

Since v3.10.0