There is an enum
called Status:
export enum Status {
SOME_VAL = "SOME_VAL",
SOME_VAL_2 = "SOME_VAL_2",
SOME_VAL_3 = "SOME_VAL_3";
}
Also, I have an interface
named SomeInterface:
export SomeInterface {
status?: Status;
}
In a simple usage of the includes
method with inline array creation in some.component.ts
:
let someVal: boolean = [Status.SOME_VAL, Status.SOME_VAL_2].includes(this.someObject.status);
Everything works fine here. But when used within the some.component.html
:
<div *ngIf="[Status.SOME_VAL, Status.SOME_VAL_2].includes(someObject.status)">
...
</div>
A warning pops up saying:
Argument type Status is not assignable to parameter type Status.SOME_VAL | Status.SOME_VAL_2
This prevents compilation. When converted to:
<div *ngIf="$any([Status.SOME_VAL, Status.SOME_VAL_2]).includes(someObject.status)">
...
</div>
The warning disappears, but unfortunately, it always evaluates to false
without any error or warning (possibly causing invisible errors). How can this issue be resolved?
An Additional Update:
I have:
Status = Status;
in my some.component.ts
, allowing me to reference it from the html
.