Skip to content

Commit

Permalink
Extend Object prototype for message instances (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-higgins-ai authored Mar 13, 2024
1 parent 14e1dfd commit d2b1db3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/runtime/src/message-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import type {UnknownMessage} from "./unknown-types";
import {binaryWriteOptions} from "./binary-writer";
import {binaryReadOptions} from "./binary-reader";

const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));

/**
* This standard message type provides reflection-based
* operations to work with a message.
Expand Down Expand Up @@ -67,7 +69,7 @@ export class MessageType<T extends object> implements IMessageType<T> {
this.typeName = name;
this.fields = fields.map(normalizeFieldInfo);
this.options = options ?? {};
this.messagePrototype = Object.defineProperty({}, MESSAGE_TYPE, { value: this });
this.messagePrototype = Object.create(null, { ...baseDescriptors, [MESSAGE_TYPE]: { value: this } });
this.refTypeCheck = new ReflectionTypeCheck(this);
this.refJsonReader = new ReflectionJsonReader(this);
this.refJsonWriter = new ReflectionJsonWriter(this);
Expand Down

0 comments on commit d2b1db3

Please sign in to comment.