[types] Check propType when checking if two types are equal

This commit is contained in:
Sathya Gunasekaran
2024-02-08 16:19:55 +00:00
parent 3c431f9afe
commit da8ca6e954
@@ -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");
}