Issue with `Schema.Class` Serialization in TanStack with Effect Typescript Library
I am running into an issue wherein
To understand the details, I want to understand the differences on Effect's side first. The code I'm using to set up the issue is this:
When invoking
This is fixed if I make
Switching to a struct has one smaller aesthetic drawback, as its type will be expanded to
Schema.Class instances are not serialisable across boundaries at the last stretch when used with TanStack Start, but Schema.Struct is. Do note, that this error happens only on TanStacks side - here's a short diagram to summarise the current flow:To understand the details, I want to understand the differences on Effect's side first. The code I'm using to set up the issue is this:
When invoking
fetchViewModel during the initial load the following error happens:This is fixed if I make
ViewModel a Schema.Struct instead rather than a class. I suppose the main difference are some added properties that are not serialisable.Switching to a struct has one smaller aesthetic drawback, as its type will be expanded to
Effect<{}> or whatever it is while Classes typically reference their proper name such as Effect<ViewModel>. What other differences should I keep in mind if I'm forced to make the data types I send across the boundary structs instead.