Package: effect
Module: Schema
This interface is used to define the annotations that can be attached to a schema. You can extend this interface to define your own annotations.
Details
Note that both a missing key or undefined is used to indicate that the
annotation is not present.
This means that can remove any annotation by setting it to undefined.
Example (Defining your own annotations)
import { Schema } from "effect"
// Extend the Annotations interface with a custom `version` annotation
declare module "effect/Schema" {
namespace Annotations {
interface Annotations {
readonly version?:
| readonly [major: number, minor: number, patch: number]
| undefined
}
}
}
// The `version` annotation is now recognized by the TypeScript compiler
const schema = Schema.String.annotate({ version: [1, 2, 0] })
// const version: readonly [major: number, minor: number, patch: number] | undefined
const version = Schema.resolveAnnotations(schema)?.["version"]
if (version) {
// Access individual parts of the version
console.log(version[1])
// Output: 2
}
Signature
export interface Annotations {
readonly [x: string]: unknown
}
Since v4.0.0