You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing mixins, I had three main issues identified. Maybe I'm not using them correctly?
Here is the reproduction of the following issues: codesandbox
Issue 1:
The static methods on mixins are present (visible via a console.log of static methods), but the mixin function doesn't seem to correctly infer the type for these static methods, since they are not present according to TypeScript inference.
Issue 2:
The order of mixins also seems to be problematic. In the provided reproduction, depending on whether the Serializable mixin is placed before or after Timestampable, the properties of one or the other are not copied. Example: put Serializable after Timestampable, the fromObject method no longer exists.
Issue 3:
Serialization of mixin properties doesn't seem to work. In the provided reproduction, if we put the Timestampable mixin first, the deserialization works fine, but the serialization does not include the properties of Timestampable.
Don't hesitate if you need more information or investigation! Tell me how I can help you 🙂
The text was updated successfully, but these errors were encountered:
static functions are not mixed by mixin, so it's more or less luck that it works for you when you put it at first argument. I generally I recommend not to use statics on entities as this makes stuff rather complicated. Try to use normal functions instead, it's cleaner.
Ok I understand better now. We were planning to remove these static methods anyway, we'll do that sooner than expected 😅 thanks for your feedback and work!
Hello again 👋
When testing mixins, I had three main issues identified. Maybe I'm not using them correctly?
Here is the reproduction of the following issues: codesandbox
The static methods on mixins are present (visible via a
console.log
of static methods), but themixin
function doesn't seem to correctly infer the type for these static methods, since they are not present according to TypeScript inference.The order of mixins also seems to be problematic. In the provided reproduction, depending on whether the
Serializable
mixin is placed before or afterTimestampable
, the properties of one or the other are not copied. Example: putSerializable
afterTimestampable
, thefromObject
method no longer exists.Serialization of mixin properties doesn't seem to work. In the provided reproduction, if we put the
Timestampable
mixin first, the deserialization works fine, but the serialization does not include the properties ofTimestampable
.Don't hesitate if you need more information or investigation! Tell me how I can help you 🙂
The text was updated successfully, but these errors were encountered: