[types] Check propType when checking if two types are equal
Sathya Gunasekaran committed
Feb 8, 2024 at 16:19 UTC
da8ca6e95400ec7ae6685ddc5cc3fdb01d4fc023
1 file changed
+13
compiler/packages/babel-plugin-react-forget/src/HIR/Types.ts
+13
@@ -143,6 +143,7 @@ export function typeEquals(tA: Type, tB: Type): boolean {
143
primitiveTypeEquals(tA, tB) ||
144
polyTypeEquals(tA, tB) ||
145
phiTypeEquals(tA, tB) ||
146
+ propTypeEquals(tA, tB) ||
147
objectMethodTypeEquals(tA, tB)
148
);
149
}
@@ -162,6 +163,18 @@ function objectMethodTypeEquals(tA: Type, tB: Type): boolean {
163
return typeKindCheck(tA, tB, "ObjectMethod");
164
}
165
166
+function propTypeEquals(tA: Type, tB: Type): boolean {
167
+ if (tA.kind === "Property" && tB.kind === "Property") {
168
+ if (!typeEquals(tA.object, tB.object)) {
169
+ return false;
170
+ }
171
+
172
+ return tA.propertyName === tB.propertyName;
173
+ }
174
+
175
+ return false;
176
+}
177
+
178
function primitiveTypeEquals(tA: Type, tB: Type): boolean {
179
return typeKindCheck(tA, tB, "Primitive");
180
}