I have a jhipster project and they just chanced the enum from this:
export enum DeclarationStatus {
NEW = 'NEW',
DRAFT = 'DRAFT',
APPROVED_BY_FREELANCER = 'APPROVED_BY_FREELANCER',
APPROVED_BY_CLIENT = 'APPROVED_BY_CLIENT',
APPROVED = 'APPROVED'
}
to this:
export enum DeclarationStatus {
NEW,
DRAFT,
APPROVED_BY_FREELANCER,
APPROVED_BY_CLIENT,
APPROVED
}
First I could do a comparison like this:
status === DeclarationStatus.APPROVED_BY_FREELANCER;
But now that does not work any more because the enum is actually a number. This does work how ever:
DeclarationStatus[''+status] === DeclarationStatus.APPROVED_BY_FREELANCER;
So my question is which is better. Or is there even a 3rd option?
I set this question to answered. The Jhipster community reverted the change to initialized. So then comparison is easy again.
Thanks to @vicpermir who made it happen.