[hir] Add a "type" field to ObjectProperty
This will be used to distinguish between a property and a method.
Sathya Gunasekaran committed
Sep 15, 2023 at 17:16 UTC
b26cc58070ed49a699b4d9d07e6f803245d8d8a1
2 files changed
+6
-1
compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts
+5
-1
@@ -34,6 +34,7 @@ import {
34
JsxAttribute,
35
ObjectPattern,
36
ObjectProperty,
37
+ ObjectPropertyKey,
38
Place,
39
ReturnTerminal,
40
SourceLocation,
@@ -1159,7 +1160,7 @@ function lowerStatement(
1160
function lowerObjectPropertyKey(
1161
builder: HIRBuilder,
1162
key: t.PrivateName | t.Expression
1162
-): { name: string; type: "string" | "identifier" } | null {
1163
+): ObjectPropertyKey | null {
1164
if (key.type === "Identifier") {
1165
return {
1166
name: key.name,
@@ -1245,6 +1246,7 @@ function lowerExpression(
1246
const value = lowerExpressionToTemporary(builder, valuePath);
1247
properties.push({
1248
kind: "ObjectProperty",
1249
+ type: "property",
1250
place: value,
1251
key: loweredKey,
1252
});
@@ -3123,6 +3125,7 @@ function lowerAssignment(
3125
}
3126
properties.push({
3127
kind: "ObjectProperty",
3128
+ type: "property",
3129
place: identifier,
3130
key: loweredKey,
3131
});
@@ -3133,6 +3136,7 @@ function lowerAssignment(
3136
);
3137
properties.push({
3138
kind: "ObjectProperty",
3139
+ type: "property",
3140
place: { ...temp },
3141
key: loweredKey,
3142
});
compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts
+1
@@ -554,6 +554,7 @@ export type ObjectPropertyKey = {
554
export type ObjectProperty = {
555
kind: "ObjectProperty";
556
key: ObjectPropertyKey;
557
+ type: "property" | "method";
558
place: Place;
559
};
560