This particular issue is causing my Angular application to malfunction. To illustrate, the const
I've defined serves as a means of testing certain values within a function. Although there are workarounds for this problem, I find it perplexing and would appreciate some insight into what exactly is happening.
The below code snippet triggers a tslint error stating that
Type '"Red"' is not comparable to type '"Green"'.
This error also occurs with if
statements.
const color = 'Red'
switch(color) {
case 'Red':
//do something
case 'Green':
//something else
}
Why is it interpreting the strings as types? Is there a reason why I can't compare a constant string variable to another string? It feels like a potential bug in the system.