Effect CommunityEC
Effect Community•14mo ago
Kofi

Issue with Schema.transformLiterals returning undefined members at runtime

When trying to retrieve the encoded or the
type
side of a Schema.transformLiterals schema via .members the data at runtime is all undefined whereas the type says that something should actually be there 🤔 is this the expected behavior?
import { Schema } from "effect"

export const URNToType = Schema.transformLiterals(
  ["type:1", "A"],
  ["type:2", "B"],
  ["type:3", "C"]
)

const encodedSide = URNToType.members.map((_) => _.Encoded)
const decodedSide = URNToType.members.map((_) => _.Type)
console.log(encodedSide) /* [undefined, undefined, undefined] expected ["type:1", "type:2, "type:3"]*/
console.log(decodedSide) /* [undefined, undefined, undefined] expected ["A", "B", "C"] */

repro: https://effect.website/play/#bd7c57ac7fd3
Was this page helpful?