An interface that extends, but has no members isn't equivalent of the supertype when interface has been already declared.
Stated by the lint description:
An interface declaring no members is equivalent to its supertype.
Use the supertype instead, or add members to this interface.
It is in fact not true, since interface ABC extends XYZ {} extends the existing ABC interface by the members of XYZ.
And in case of the interface being defined for the first time, the same applies – it can be later extended with other interface declarations, where type cannot.
type MappedType = {
[thing in "a" | "b" | "c"]: true;
};
interface ABC extends MappedType {}; // workaround around not being able to use mapped types in interfaces. This allows `ABC` to be extended with other interface declarations.
interface ABC {
abc: true;
}
TypeEquals<ABC, {
abc: true;
a: true;
b: true;
c: true;
}>;
Expected Result
interface ABC {} should error out for being empty
interface ABC extends XYZ {} shouldn't error
Actual Result
interface ABC extends XYZ {} errors
Additional Info
interface ABC extends XYZ {} can be useful in scenarios, where global namespaces are augmented to allow extending given type definitions by the module.
An interface that extends, but has no members isn't equivalent of the supertype when interface has been already declared.
Stated by the lint description:
It is in fact not true, since
interface ABC extends XYZ {}
extends the existingABC
interface by the members ofXYZ
. And in case of the interface being defined for the first time, the same applies – it can be later extended with otherinterface
declarations, wheretype
cannot.Lint Name
no-empty-interface
Code Snippet
Expected Result
interface ABC {}
should error out for being emptyinterface ABC extends XYZ {}
shouldn't errorActual Result
interface ABC extends XYZ {}
errorsAdditional Info
interface ABC extends XYZ {}
can be useful in scenarios, where global namespaces are augmented to allow extending given type definitions by the module.Version