Hyperlinkv0.8.0-beta.28

Schema

Schema.revealCodecfunctioneffect/Schema.ts:1002
<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>

Returns a codec widened to the full Codec interface, prompting TypeScript to infer all four type parameters (T, E, RD, RE).

Details

When a schema is stored in a variable typed as Schema<T> or Top, the encoded type and service requirements are erased. Passing the value through revealCodec recovers those parameters without any runtime cost.

Example (Recovering encoded type from a schema variable)

import { Schema } from "effect"

const schema: Schema.Schema<number> = Schema.NumberFromString

// Without revealCodec, Encoded is unknown
const codec = Schema.revealCodec(schema)
type Enc = typeof codec["Encoded"] // string
utility typesCodec
Source effect/Schema.ts:10023 lines
export function revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>) {
  return codec
}