Allow me to simplify the question with an example.
type TypeA = 1 | 2;
type TypeB = 3 | 4;
type TypeC = TypeA | TypeB;
const arrayA: TypeA[] = [1, 2];
const arrayB: TypeC[] = [1, 2, 3, 4];
arrayB.forEach((element) => {
arrayA.includes(element);
^^^
});
The argument of type TypeC
cannot be assigned to a parameter of type TypeA
.
Type 3
cannot be assigned to type TypeA
.
I understand why it didn't work, but I am struggling to find any solutions to check if arrayA
contains an element of element
.