mobxjs / serializr

Serialize and deserialize complex object graphs to and from JSON and Javascript classes
MIT License
766 stars 52 forks source link

modelSchemaOrInstance with static toString will call toString #141

Closed Unity-G closed 3 years ago

Unity-G commented 4 years ago

I am using "serializr": "2.0.3"

Using something as: ` class MyClass { @serializable Data: string;

static toString(myObj: MyClass): string {
    debugger;
}

} `

Calling serialize(MyClass, new MyClass()); will call "toString";

Due to: 415:serialir.js invariant(foundSchema, "Failed to find default schema for " + modelSchemaOrInstance);

Having "+ modelSchemaOrInstance" will call the static toString of the modelSchemaOrInstance.

Fix: 415:serialir.js invariant(foundSchema, "Failed to find default schema for " + modelSchemaOrInstance.name);

Hope it helps