The following code does what I want it to do:
BallStatusTypes.safe === BallStatusTypes[status] ? 'ball' : 'ball-danger'
Despite giving me this error: This condition will always return 'false' since the types 'BallStatusTypes' and 'string' have no overlap.
The following, error free code does NOT do what I want it to do:
status === BallStatusTypes.safe ? 'ball' : 'ball-danger'
The enum is:
export enum BallStatusTypes {
danger = 1,
safe = 2
}
How can I fix my code so that it does what I want it to do, without errors?
I ended up resolving this with:
export enum BallStatusTypes {
danger = 'danger',
safe = 'safe'
}
It seems I was having issues with the way enums create objects mapping to either a number or a string. And, typescript was unaware (when performing expressions on said value) of weather or not it should be comparing the numerical version or the string version of the status.