Open sdalexandre opened 3 years ago
It would be possible to do by declaring a toJSON() method in the class, if present it gets called from JSON.stringify(). However, @Model overrides toJSON() on the class prototype. I could make it that if toJSON is already declared it wont get overridden (with a warning).
Because I want to specify a class that behave like a type.
For example:
will be serialized this way:
{counter: { [key: string]: number; }}
but I would like it to be this way directly:
{ [key: string]: number; }
I'm currently declaring:
type MyCounterType = { [key: string]: number; }
with the drawback that a type doesn't have methods and I have to create another class for this: