TypeScript being grumpy with includes when comparing string[] to MyType[]

So I'm currently working on some checkboxes which correlate to some values for rent syndication. The values are strings of numbers, like this: ['12', '13', '14'] So I'm wanting to check to see if the checked box's value already exists in the array of these values. the values are a string[] as a type. But I have a type of the checkboxes that I'm working on since they pertain specifically to pets. So I have this: (petPolicyValue) => !amenitiesPets.includes(petPolicyValue) But I get an error like this: Argument of type 'string' is not assignable to parameter of type 'PetAmenityValues'. So I'm curious... why does include work like this? If it wasn't possible to be included it would just return false, which is what I want, but I understand that my types don't overlap correctly. Is there a good way around this?
2 Replies
Matvey
Matvey2y ago
['12', '13', ...] as MyType[]
Kyle
Kyle2y ago
I think I misrepresented what I was saying but I fixed it in another way, I just made the arrays more broad
Want results from more Discord servers?
Add your server