Effect CommunityEC
Effect Community•3y ago•
3 replies
TheStockBroker

Modeling Annoying State with Minimal Schemas

How do I model annoying state like the following:
type DataFoo = {
  type: "Foo",
  number: number,
  data: Foo
}
type DataBar = {
  type: "Bar",
  number: number,
  data: Bar
}

type Data = DataFoo | DataBase
type GenericData = {
  type: "Foo" | "Bar"
  number: number
  data: Foo | Bar
}

in the least amount of schemas? 😃
Was this page helpful?