Hyperlinkv0.8.0-beta.28

SchemaGetter

SchemaGetter.passthroughfunctioneffect/SchemaGetter.ts:233
<T, E>(options: { readonly strict: false }): Getter<T, E>
<T>(): Getter<T, T>

Returns the identity getter — passes the value through unchanged.

When to use

Use when you need a schema getter for one side of a decodeTo pair, either encode or decode, to pass values through unchanged.

Details

  • Pure, no allocation (singleton instance).
  • Optimized away during .compose() — composing with a passthrough is free.
  • The default overload requires T === E. Pass { strict: false } to opt out of the type constraint.

Example (Passing through identity transformations)

import { Schema, SchemaGetter } from "effect"

// No transformation needed — types already match
const StringToString = Schema.String.pipe(
  Schema.decodeTo(Schema.String, {
    decode: SchemaGetter.passthrough(),
    encode: SchemaGetter.passthrough()
  })
)
export function passthrough<T, E>(options: { readonly strict: false }): Getter<T, E>
export function passthrough<T>(): Getter<T, T>
export function passthrough<T>(): Getter<T, T> {
  return passthrough_
}
Referenced by 9 symbols