Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/runtime/src/message-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import type {UnknownMessage} from "./unknown-types";
import {binaryWriteOptions} from "./binary-writer";
import {binaryReadOptions} from "./binary-reader";

const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));
const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})) as Record<typeof MESSAGE_TYPE, unknown>;
const messageTypeDescriptor = baseDescriptors[MESSAGE_TYPE] = {} as {value?: unknown};

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