Handling Nested Schema Classes in Effect Typescript Library

I have run into some unexpected behavior when using nested Schema.Class and I am wondering if there is a way around it or if its just bad practice. I have an example like this

...

export class PropertyDefinition extends Schema.Class<PropertyDefinition>(
  "PropertyDefinition"
)({
  id: PropertyDefinitionId,
  name: Schema.String, 
  ...
}) {}

export class EntityDefinition extends Schema.Class<EntityDefinition>(
  "EntityDefinition"
)({
  id: EntityDefinitionId,
  name: Schema.String,
  properties: Schema.Array(PropertyDefinition),
}) {}


when I do something like this

const entity = Entitydefinition.make({
...
properties: [{ 
    id: "...",
    name: "...",
    ...
    }]
})


and provide the values of properties but not instances of PropertyFilter, then I get no typescript error, but I do get a runtime error

EntityDefinition (Constructor)
└─ ["properties"]
   └─ ReadonlyArray<PropertyDefinition>
      └─ [0]
         └─ Expected PropertyDefinition, actual


Is there a better way to do this that either gives me a compile error or avoids the runtime error? I dont really want to use Schema.decode/encode since i am just instantiating the object and will then encode later
Was this page helpful?