All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.S6578.html Maven / Gradle / Ivy

There is a newer version: 10.20.0.29356
Show newest version

Why is this an issue?

TypeScript allows assigning values to enum members. However, it does not enforce uniqueness between the values of such members. As a result, assigning the same value to different members is possible.

The rule raises issues on duplicate values because they are misleading and can lead to bugs that are hard to track down.

How to fix it

Assign a unique value for each enum member or don’t assign any values.

Code examples

Noncompliant code example

enum E {
  X = 0,
  Y = 0,
}

Compliant solution

enum E {
  X = 0,
  Y = 1,
}

Resources

Documentation

  • typescriptlang.org/docs/handbook/enums.html[TypeScript Enums]




© 2015 - 2025 Weber Informatics LLC | Privacy Policy