Effect CommunityEC
Effect Community3y ago
13 replies
TheStockBroker

Decoding Unknown Shapes Inside Known Shapes

if I have an unknown or opaque shape inside a known shape. How can I decode it correctly?
type I = {
  foo: string // known
  bar: unknown
  baz: Json // opaque
}

type A = {
  foo: string
  bar: number
  baz: { qux: "Qux" }
}

I want to be able to decode and not have to parse.
Should I cast my Bar to Schema<unknown, number> and my Baz to Schema<Json, {...}>?
Basically I want my encode to have a safe-ish parse inside it
Was this page helpful?