effect-io-ai

Package: effect
Module: Data

Data.tagged

Provides a tagged constructor for the specified Case.

Example

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

interface Person {
  readonly _tag: "Person" // the tag
  readonly name: string
}

const Person = Data.tagged<Person>("Person")

const mike = Person({ name: "Mike" })

assert.deepEqual(mike, { _tag: "Person", name: "Mike" })

Signature

declare const tagged: <A extends { readonly _tag: string; }>(tag: A["_tag"]) => Case.Constructor<A, "_tag">

Source

Since v2.0.0