Issue with encoding in TypeScript code

Uhm, not sure if something wrong on my usage, but I think I encountered this strange situation, here's a minimal repro where I expect it to succeed encoding, instead I get the following:

const PodAddressSymbolKey = "effect/cluster/PodAddress"
const PodAddressTypeId = Symbol.for(PodAddressSymbolKey)
const PodAddressSchema = Schema.data(
  Schema.rename(
    Schema.struct({
      [PodAddressSymbolKey]: Schema.compose(
        Schema.symbolFromString(Schema.literal(PodAddressSymbolKey)),
        Schema.uniqueSymbol(PodAddressTypeId)
      ),
      host: Schema.string
    }),
    { [PodAddressSymbolKey]: PodAddressTypeId }
  )
)

const PodSymbolKey = "effect/cluster/Pod"
const PodTypeId = Symbol.for(PodSymbolKey)
const PodSchema = Schema.data(Schema.rename(
  Schema.struct({
    [PodSymbolKey]: Schema.compose(
      Schema.symbolFromString(Schema.literal(PodSymbolKey)),
      Schema.uniqueSymbol(PodTypeId)
    ),
    address: PodAddressSchema
  }),
  { [PodSymbolKey]: PodTypeId }
))

console.log(
  "out",
  Schema.encodeSync(PodSchema)(
    Data.struct({
      [PodTypeId]: PodTypeId,
      address: Data.struct({ [PodAddressTypeId]: PodAddressTypeId, host: "localhost" })
    })
  )
)

/**
Error: error(s) found
└─ ["address"]
   └─ Expected Data, actual {"host":"localhost","effect/cluster/PodAddress":"effect/cluster/PodAddress"}
 */
Was this page helpful?