From da8ca6e95400ec7ae6685ddc5cc3fdb01d4fc023 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Thu, 8 Feb 2024 16:19:55 +0000 Subject: [PATCH] [types] Check propType when checking if two types are equal --- .../babel-plugin-react-forget/src/HIR/Types.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/Types.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/Types.ts index 0aa61913bd..ea0c6c0909 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/Types.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/Types.ts @@ -143,6 +143,7 @@ export function typeEquals(tA: Type, tB: Type): boolean { primitiveTypeEquals(tA, tB) || polyTypeEquals(tA, tB) || phiTypeEquals(tA, tB) || + propTypeEquals(tA, tB) || objectMethodTypeEquals(tA, tB) ); } @@ -162,6 +163,18 @@ function objectMethodTypeEquals(tA: Type, tB: Type): boolean { return typeKindCheck(tA, tB, "ObjectMethod"); } +function propTypeEquals(tA: Type, tB: Type): boolean { + if (tA.kind === "Property" && tB.kind === "Property") { + if (!typeEquals(tA.object, tB.object)) { + return false; + } + + return tA.propertyName === tB.propertyName; + } + + return false; +} + function primitiveTypeEquals(tA: Type, tB: Type): boolean { return typeKindCheck(tA, tB, "Primitive"); }