Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.passthroughSubtypefunctioneffect/SchemaTransformation.ts:772
<T, E extends T>(): Transformation<T, E>

Transforms values without changing them, typed so that E extends T — the encoded type is a subtype of the decoded type.

When to use

Use when you need a no-op schema transformation whose encoded side is more specific than its decoded side.

Details

  • Both decode and encode are no-ops (same as passthrough).
  • Returns a shared singleton instance.

Example (Passing through subtypes)

import { SchemaTransformation } from "effect"

const t = SchemaTransformation.passthroughSubtype<string, "a" | "b">()
export function passthroughSubtype<T, E extends T>(): Transformation<T, E>
export function passthroughSubtype<T>(): Transformation<T, T> {
  return passthrough_
}