Tengo 2 enumeraciones:
enum Insurer { PREMERA = 'premera_blue_cross', UHC = 'united_health_care' } enum ProductSource { PremeraBlueCross = 'premera_blue_cross', UnitedHealthCare = 'united_health_care' }
Intento verificar si la matriz de Aseguradora incluye ProductSource:
const insurerArr: Insurer[] = [Insurer.PREMERA, Insurer.UHC] insurerArr.includes(ProductSource.PremeraBlueCross)
Pero obtuve un error del compilador TS:
Argument of type 'ProductSource' is not assignable to parameter of type 'Insurer'.
¿Hay alguna manera de comparar sin hacer una conversión a la string
y luego a la otra enumeración?
Es posible que desee considerar cambiar a type
en lugar de enum
:
type Insurer = 'premera_blue_cross' | 'united_health_care'; type ProductSource = 'premera_blue_cross' | 'united_health_care'; const insurerArr: Insurer[] = ['premera_blue_cross', 'united_health_care']; insurerArr.includes('premera_blue_cross');