46 lines
1.0 KiB
Plaintext

== 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
[source,javascript]
----
interface A {} // Noncompliant
----
=== Compliant solution
[source,javascript]
----
interface A {
foo: number;
}
----
=== Exceptions
No issue is raised if the empty interface extends a https://www.typescriptlang.org/docs/handbook/utility-types.html[TypeScript utility type].
[source,javascript]
----
interface A {
foo: number;
bar: string;
}
interface B extends Pick<A, 'foo'> {}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]