vendredi 10 septembre 2021

React - if multiply one line

I tried this if in my react project.

if (
  (role !== UserRoleEnum.Admin || role !== UserRoleEnum.Employee) &&
  (project.state === ProjectState.online || project.state === ProjectState.onhold)
) { }

I get this error back

This condition will always return 'true' since the types 'UserRoleEnum.Admin' and 'UserRoleEnum.Employee' have no overlap. TS2367

How can i set this best up, that i got all in one if statement.

I want to check if

  • user is not Admin or not Employee and
  • project state is Online or OnHold

Aucun commentaire:

Enregistrer un commentaire