diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts index 6f51d5a9c1..d07d3f2082 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts @@ -1246,7 +1246,7 @@ function lowerExpression( properties.push({ kind: "ObjectProperty", place: value, - ...loweredKey, + key: loweredKey, }); } else if (propertyPath.isSpreadElement()) { const place = lowerExpressionToTemporary( @@ -3125,7 +3125,7 @@ function lowerAssignment( properties.push({ kind: "ObjectProperty", place: identifier, - ...loweredKey, + key: loweredKey, }); } else { const temp = buildTemporaryPlace( @@ -3135,7 +3135,7 @@ function lowerAssignment( properties.push({ kind: "ObjectProperty", place: { ...temp }, - ...loweredKey, + key: loweredKey, }); followups.push({ place: temp, path: element as NodePath }); // TODO remove type cast } diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts index 3b8dd72205..75ade2c0a3 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts @@ -546,10 +546,14 @@ export type ObjectPattern = { properties: Array; }; -export type ObjectProperty = { - kind: "ObjectProperty"; +export type ObjectPropertyKey = { type: "string" | "identifier"; name: string; // TODO: make a Place +}; + +export type ObjectProperty = { + kind: "ObjectProperty"; + key: ObjectPropertyKey; place: Place; }; diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts index 4b840b9ea3..04cf43facd 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts @@ -19,7 +19,7 @@ import { InstructionValue, LValue, MutableRange, - ObjectProperty, + ObjectPropertyKey, Pattern, Phi, Place, @@ -263,12 +263,12 @@ function printHole(): string { return ""; } -function printObjectPropertyKey(property: ObjectProperty): string { - switch (property.type) { +function printObjectPropertyKey(key: ObjectPropertyKey): string { + switch (key.type) { case "identifier": - return property.name; + return key.name; case "string": - return `'${property.name}'`; + return `'${key.name}'`; } } @@ -295,7 +295,7 @@ export function printInstructionValue(instrValue: ReactiveValue): string { for (const property of instrValue.properties) { if (property.kind === "ObjectProperty") { properties.push( - `${printObjectPropertyKey(property)}: ${printPlace( + `${printObjectPropertyKey(property.key)}: ${printPlace( property.place )}` ); @@ -631,7 +631,7 @@ export function printPattern(pattern: Pattern | Place | SpreadPattern): string { .map((item) => { switch (item.kind) { case "ObjectProperty": { - return `${printObjectPropertyKey(item)}: ${printPattern( + return `${printObjectPropertyKey(item.key)}: ${printPattern( item.place )}`; } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts index 9add710317..e4a2855942 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -16,7 +16,7 @@ import { IdentifierId, InstructionKind, JsxAttribute, - ObjectProperty, + ObjectPropertyKey, Pattern, Place, ReactiveBlock, @@ -937,14 +937,14 @@ function codegenInstructionValue( const properties = []; for (const property of instrValue.properties) { if (property.kind === "ObjectProperty") { - const key = codegenObjectPropertyKey(property); + const key = codegenObjectPropertyKey(property.key); const value = codegenPlace(cx, property.place); properties.push( t.objectProperty( key, value, false, - value.type === "Identifier" && value.name === property.name + value.type === "Identifier" && value.name === property.key.name ) ); } else { @@ -1356,13 +1356,13 @@ function convertMemberExpressionToJsx( } function codegenObjectPropertyKey( - property: ObjectProperty + key: ObjectPropertyKey ): t.StringLiteral | t.Identifier { - switch (property.type) { + switch (key.type) { case "identifier": - return t.identifier(property.name); + return t.identifier(key.name); case "string": - return t.stringLiteral(property.name); + return t.stringLiteral(key.name); } } @@ -1384,13 +1384,13 @@ function codegenLValue( return t.objectPattern( pattern.properties.map((property) => { if (property.kind === "ObjectProperty") { - const key = codegenObjectPropertyKey(property); + const key = codegenObjectPropertyKey(property.key); const value = codegenLValue(property.place); return t.objectProperty( key, value, false, - value.type === "Identifier" && value.name === property.name + value.type === "Identifier" && value.name === property.key.name ); } else { return t.restElement(codegenLValue(property.place)); diff --git a/compiler/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts b/compiler/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts index c256787786..2a606f415b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts +++ b/compiler/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts @@ -236,7 +236,7 @@ function* generateInstructionTypes( yield equation(property.place.identifier.type, { kind: "Property", object: value.value.identifier.type, - propertyName: property.name, + propertyName: property.key.name, }); } }