org.sonar.l10n.javascript.rules.javascript.S4023.html Maven / Gradle / Ivy
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'> {}