I have declared an enum in typescript as follows:
enum MultiPhaseUnits {
AMPERAGE = 'AMPERAGE',
VOLTAGE = 'VOLTAGE',
POWER_FACTOR = 'POWER_FACTOR',
LINE_VOLTAGE = 'LINE_VOLTAGE'
}
and created an array of enum values as such:
this.multiPhaseUnits = [MultiPhaseUnits.AMPERAGE, MultiPhaseUnits.LINE_VOLTAGE, MultiPhaseUnits.POWER_FACTOR, MultiPhaseUnits.VOLTAGE];
My problem is that when I go to check if a string is included in this array, VScode says parameter of type string is not assignable to parameter of type MultiPhaseUnit. For example:
if (this.multiPhaseUnits.indexOf(queryable.unit.apiUnit) > -1) {...}
It puts a red squiggly under queryable.unit.apiUnit, where apiUnit is a string in the form AMPERAGE, LINE_VOLTAGE.... I have verified this code will work and verified that the array multiPhaseUnits[] will end up essentially being an array of strings. Why is VScode complaining about this check? Even though my code works, if I am doing something wrong, how can I fix it?