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

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

There is a newer version: 10.17.0.28100
Show newest version

Why is this an issue?

An empty interface is equivalent to an empty object ('{}'). Normally you cannot directly assign an object literal to a type when the object literal contains more properties than are specified in the type. But in the case of an empty interface, this check is not done, and such assignments will be successful. The result is highly likely to confuse maintainers.

Noncompliant code example

interface A {}  // Noncompliant

Compliant solution

interface A {
  foo: number;
}

Exceptions

No issue is raised if the empty interface extends a TypeScript utility type.

interface A {
  foo: number;
  bar: string;
}

interface B extends Pick<A, 'foo'> {}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy