Trouble Defining a Schema.Struct Factory in TypeScript

Not able to define a Schema.Struct Factory

Hi all, I must be missing something simple in my attempt to define a Schema.Struct Factory

The very basic version of what I would like to do is:
const DataStructFact = <
  D extends Schema.Struct<any>
>(D: D) =>
  Schema.Struct({
    ...DataM.fields,
    ...D.fields
  })


The issue with with approach is that the fields of D are not part of the constructed Struct

Another approach, using Schema.extend leads to other issues when using the constructed Struct with Schema.class ():
const dataProps = DataStructFact(props)
export class AnalyticsUI extends Schema.Class<AnalyticsUI>("AnalyticsUI")(
  dataProps
) {}

Complaining that dataProps "is missing the following properties from type 'Struct<Fields>': fields, records, make, pick, omit".

Is this approach an anti-pattern ?
Was this page helpful?