After https://github.com/timostamm/protobuf-ts/pull/582, message instances don't behave exactly like simple objects, as their prototype only includes a Symbol("protobuf-ts/message-type") field and is missing fields normally present in a simple object (e.g. constructor). For us, this specifically causes an issue when using mobx to observe changes to message instances - it only allows observing objects that have a constructor method in their prototype that matches the method for simple objects.
This fixes the problem by copying the default object prototype and adding a Symbol("protobuf-ts/message-type") field, rather than starting from an empty prototype.
After https://github.com/timostamm/protobuf-ts/pull/582, message instances don't behave exactly like simple objects, as their prototype only includes a
Symbol("protobuf-ts/message-type")
field and is missing fields normally present in a simple object (e.g.constructor
). For us, this specifically causes an issue when using mobx to observe changes to message instances - it only allows observing objects that have aconstructor
method in their prototype that matches the method for simple objects.This fixes the problem by copying the default object prototype and adding a
Symbol("protobuf-ts/message-type")
field, rather than starting from an empty prototype.