Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.passthroughSupertypefunctioneffect/SchemaTransformation.ts:739
<T extends E, E>(): Transformation<T, E>

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

When to use

Use when you need a no-op schema transformation whose decoded side is narrower than the encoded side.

Details

Both decode and encode are no-ops and return a shared singleton transformation.

Example (Passing through supertypes)

import { SchemaTransformation } from "effect"

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