Skip to content

Commit

Permalink
support symbols as property keys
Browse files Browse the repository at this point in the history
  • Loading branch information
andrfra committed Apr 15, 2024
1 parent 75553f5 commit 5894e2b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/reactivity-core/collections/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,16 @@ function preparePrototype<T>(
definition: ReactiveStructDefinition<T>
): PrepareResult<T> {
const propertyKeys = Object.keys(definition) as (keyof T & (string | symbol))[];
const propertySymbols = Object.getOwnPropertySymbols(definition) as (keyof T & (symbol))[];

const allKeys = [...propertyKeys, ...propertySymbols];

// Initialization steps for certain properties.
// These are run from the class instance's constructor to prepare an instance.
type InitStep = (instance: any, storage: PrivateStorage, initialArgs?: Partial<T>) => void;
const initSteps: InitStep[] = [];

for (const propertyKey of propertyKeys) {
for (const propertyKey of allKeys) {
const memberDef = definition[propertyKey];
if ("method" in memberDef) {
Object.defineProperty(prototype, propertyKey, {
Expand Down

0 comments on commit 5894e2b

Please sign in to comment.