Incorporating the @types/fabric package into my application has raised a query for me. I'm eager to utilize predefined interfaces such as ICircleOptions
, IRectOptions
, and others from fabric types.
Is there a way to use these interfaces in conjunction with the io-ts library for runtime type checking?
My current approach involves defining a type like this:
const Response = t.type({
id: t.number,
type: t.string,
objects: t.array(t.union([ICircleOptions, IRectOptions]))
})
The objective is to integrate fabric's predefines interfaces within the type definition for the objects array.
While browsing through https://github.com/gcanti/io-ts/issues/209, I noticed an example shared by the author of io-ts. However, it doesn't seem to work in my case.
I would greatly appreciate any guidance on whether this integration is feasible or not. Thank you.