Skip to content

Commit d2b1db3

Browse files
Extend Object prototype for message instances (#618)
1 parent 14e1dfd commit d2b1db3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/runtime/src/message-type.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import type {UnknownMessage} from "./unknown-types";
1919
import {binaryWriteOptions} from "./binary-writer";
2020
import {binaryReadOptions} from "./binary-reader";
2121

22+
const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));
23+
2224
/**
2325
* This standard message type provides reflection-based
2426
* operations to work with a message.
@@ -67,7 +69,7 @@ export class MessageType<T extends object> implements IMessageType<T> {
6769
this.typeName = name;
6870
this.fields = fields.map(normalizeFieldInfo);
6971
this.options = options ?? {};
70-
this.messagePrototype = Object.defineProperty({}, MESSAGE_TYPE, { value: this });
72+
this.messagePrototype = Object.create(null, { ...baseDescriptors, [MESSAGE_TYPE]: { value: this } });
7173
this.refTypeCheck = new ReflectionTypeCheck(this);
7274
this.refJsonReader = new ReflectionJsonReader(this);
7375
this.refJsonWriter = new ReflectionJsonWriter(this);

0 commit comments

Comments
 (0)